The more advanced file-handling (like directory searching) is situated in EDirTree
TYPE ArchiveType = ( none,SQZ, ZIP, HPK, ZOO, LZH, ARJ, DWC, ARC, PAK, A7P, HYP, RAR, Q, UC2, Gif, LBM, PCX, WAV, BMP);This ordinal type is used by ArchiveMethod to indicate the archivetype.
WrBinary | WrLngBinary |
WrOct | WrLngOct |
WrHex | WrLngHex |
Declaration
FUNCTION ArchiveMethod( FileName : String) : ArchiveType;
Description
Returns the archive/file type of the filename passed as a parameter.
Right now the following types are supported, or at least prepared in the type.
ARJ, ZIP, LZH, UC2,RAR | implemented and tested |
SQZ, HPK, Zoo | are implemented but untested |
ARC, PAK, A7P, HYP | tunimplemented, but I have some routines for these packers, but I have to decrypt the assembler |
DWC | No algoritm present, only included in type because somebody said he had a detectionprocedure, but he never send it |
GIF, LBM, PCX, WAV, BMP | Implemented and seems to work. Most of these formats come in different flavours, so an additional detection routine might be necessary. |
See Also ArchiveType
Notes
Declaration
FUNCTION FileExists(FileName: String): Boolean;
Description
A boolean function that returns True if the file exists, otherwise, it returns False. Closes the file if it exists, copied from the BP7 help.
Note : Seems not to work for a directory.
Declaration
FUNCTION ExtensionPos ( CONST s : String) : WORD;
Description
Returns the position of the extension in path s, or MAX(WORD) (=65535) if not found. Actually this procedure was internal, but the procedure can be used to check if extension exists, so I moved it to the interface.
See Also:
Declaration
PROCEDURE RemoveExtension ( VAR s : String) ;
Description
Strip extension from path in S.
See Also:
Declaration
PROCEDURE AddExtension ( VAR s : String; CONST Extension : String) ;
Description
Append Extension to path in s. Path isn't allowed to have an extension.
See Also:
Declaration
PROCEDURE ChangeExtension ( VAR s : String; CONST Extension : String) ;
Description
Change the (potentially existant) extension of S to Extension
See Also:
CAUTION, THIS IS A DANGEROUS COMMAND, USE WITH CARE!
Declaration
PROCEDURE Deldir(Dir : PathStr);
Description
Recursively removes all contents of DIR, hidden files and directories inclusive, like MsDos Deltree, or Linux rm -rf.
Note :
Declaration
PROCEDURE WrHex (InValue:WORD); or
PROCEDURE WrHex (VAR F : Text;InValue:WORD);
Description
Write the WORD-typed value in an hexadecimal representation to either screen or text-file. The procedure always outputs 4 characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrLngHex(InValue:CARDINAL); or
PROCEDURE WrLngHex(VAR F:Text;InValue:CARDINAL);
Description
Write the CARDINAL-typed value in an hexadecimal representation to either screen or text-file. The procedure always outputs 8 characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrOct (InValue:WORD); or
PROCEDURE WrOct (VAR F : Text;InValue:WORD);
Description
Write the WORD-typed value as in an octal representation to either screen or text-file. The procedure always outputs 6 (16/3=5.3, rounded up) characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrLngOct(InValue:CARDINAL); or
PROCEDURE WrLngOct(VAR F:Text;InValue:CARDINAL);
Description
Write the CARDINAL-typed value as in an octal representation to either screen or text-file. The procedure always outputs 11 (32/3 rounded up) characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrBinary (InValue:WORD); or
PROCEDURE WrBinary (VAR F : Text;InValue:WORD);
Description
Write the WORD-typed value in a binary representation to either screen or text-file. The procedure always outputs 16 characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrLngBinary (InValue:CARDINAL); or
PROCEDURE WrLngBinary (VAR F:Text;InValue:CARDINAL);
Description
Write the CARDINAL-typed value in a binary representation to either screen or text-file. The procedure always outputs 32 characters, left-padded with 0.
See Also:
Declaration
PROCEDURE WrStrAdj(CONST InS: String;L : LONGINT);
PROCEDURE WrStrAdj(VAR F: Text;CONST InS: String;L : LONGINT);
Description
Assuming that S is type STRING, WrStrAdj(S,L). Is the same as write(S:L), however WrStrAdj(S:-L) pads on the other side.
Declaration
PROCEDURE FileAppend(VAR F: Text;FileName:String);
Description
Roughly equal to:
Assign (F,FileName); Append (F);but this function creates the file if it doesn't exist, instead of a runtime error.
Example:
VAR F: Text; BEGIN FileAppend(F,'system.log'); {Append, create if not exists} Writeln(F,'New Entry'); Close(F); END.
Declaration
PROCEDURE MkFullDir(CONST InPath:String);
Description
Shell to MkDir command, creates several directories at once:
MkFullDir('D:\programming\FPC\RELEASE\0.99.8/Binaries'); creates the entire path, even if d:\programming doesn't exist. D: has to exist however.
The procedure only tries to create the right directory separator. It accepts both back- as forward slashes, and only outputs (to mkdir) backslashes(dos) or forwardslashes (Linux). I don't think this is necessary under FPC (the entire RTL allows both forward as backward slashes), but it might ease porting units back to Borland Pascal.
Based on the following RTL procedures : FindFirst, MkDir and FExpand. Errors(e.g. non existing driveletters) are handled by those procedures
Example:
BEGIN MkFullDir('c:\program files\XtdFpc Soft\XtdFpc\Libsrc\'); END.
Declaration
PROCEDURE Touch(Const FileName:String);
Description
Simply touch command (Set filetimedate of file(s) to current datetime). Directories and wildcards supported. NOT recursive. Use EdirTree to run a procedure recursive.
Example:
BEGIN Touch('c:\program files\*.*'); END.