The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information.... |
Home ![]() ![]() ![]() |
|
Interface of SDL_FileSys |
|
const {$IFDEF PAIDVERS} SDLVersionInfo = 'filesys_r1070_full'; IsLightEd = false; {$ELSE} SDLVersionInfo = 'filesys_r1070_lighted'; IsLightEd = true; {$ENDIF} release = 1070; type ESDLFileSysError = class(ESDLError); { exception type to indicate errors } TTextfileType = (tftUnicode_le, tftUnicode_be, tftUnicode4_le, tftUnicode4_be, tftRTF, tftUTF8, tftUnknown); TNumericFeedback = procedure (Sender: TObject; const num: double) of object; { procedure type for general numeric feedback events } TStringFeedback = procedure (Sender: TObject; const msg: string) of object; { procedure type for general string feedback events } TScanFilesFeedback = procedure (CurrentDir: string; Count: longint); { procedure type for callback routine of ScanFilesToStrList } TFileCopyFeedBack = procedure (BytesCopied, SizeOfFile: longint); { procedure type for callback routine during filecopy } TTreeCopyFeedBack = procedure (BytesCopied, SizeOfCurrentFile: longint; NameOfCurrentFile: string; NrOfFilesCopiedSoFar: longint); { procedure type for callback routine during filecopy } TOnFileSelectEvent = procedure (Sender: TObject; Parameters: string; var UserAction: TModalResult; var SelectedFileName: string) of object; TOnFileCheckEvent = procedure (Sender: TObject; FileName: string; var FileDoesExist: boolean) of object; TOnOverwriteEvent = procedure (Sender: TObject; FileName: string; var OverwriteReply: TModalResult) of object; TOnForbiddenDirEvent = procedure (Sender: TObject; Path: string; var ForbiddenDirReply: TModalResult) of object; {$IFDEF GE_LEV18} TUnivSaveDialog = class (TCommonDialog) {$ELSE} TUnivSaveDialog = class (TComponent) {$ENDIF} private FParams : string; FFileName : string; FOnFileSelect : TOnFileSelectEvent; FOnFileCheck : TOnFileCheckEvent; FOnOverwrite : TOnOverwriteEvent; FOnForbiddenDir : TOnForbiddenDirEvent; FUseStdDiag : boolean; FFilterIndex : integer; FForbiddenDir : string; {$IFDEF GE_LEV18} SDiag : TFileSaveDialog; procedure SaveDiagTypeChange(Sender: TObject); {$ENDIF} function IsForbiddenDir (FPath: string): boolean; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; function Execute: boolean; property FileName: string read FFileName write FFileName; property FilterIndex: integer read FFilterIndex write FFilterIndex; property ForbiddenDir: string read FForbiddenDir write FForbiddenDir; function ExtractParamAsInt (ParName: string): integer; function ExtractParamAsDouble (ParName: string): double; function ExtractParamAsString (ParName: string): string; published property Parameters: string read FParams write FParams; property OnFileSelect: TOnFileSelectEvent read FOnFileSelect write FOnFileSelect; property OnFileCheck: TOnFileCheckEvent read FOnFileCheck write FOnFileCheck; property OnOverwrite: TOnOverwriteEvent read FOnOverwrite write FOnOverwrite; property OnForbiddenDir: TOnForbiddenDirEvent read FOnForbiddenDir write FOnForbiddenDir; property UseStandardDialog: boolean read FUseStdDiag write FUseStdDiag; end; procedure AbortAnyFileCopying; function AbridgeFilePath (Path : string; { file path to be abridged } MaxLength : integer) { maximum lenth of resulting string } : string; { abridged file path } procedure AppendToTextFile (FName : string; { file name of text file } SL : TStringList); overload; { string list to be appended } procedure AppendToTextFile (FName, { file name of text file } Text : string); overload; { string to be appended } procedure BuildDriveList (DrvList : TStringList); { string list returning all avail. drives } {$IFNDEF DOTNET} function CheckTextFileType (FName : string) { file name of text file } : TTextFileType; { type of text file } {$ENDIF} function CountFiles (FileMask : string; { filemask of files to be included } SubDirs : boolean; { TRUE: recursive search in subdirectories } Feedback : TScanFilesFeedback) { feedback during counting } : integer; { number of files found } function CountLinesInTextFile (const FVar : TextFile; { open text file } FeedBack : TFeedBackProc) { feedback during counting } : integer; overload; { number of lines in text file } function CountLinesInTextFile (const FName : string; { name of text file } FeedBack : TFeedBackProc) { feedback during counting } : integer; overload; { number of lines in text file } function DelDirTree (path : string) { path to be deleted } : string; { empty if OK, else path which caused problems } {- $IFNDEF GE_LEV13} function DeleteFiles (FileMask : string) { mask for file selection } : integer; { number of deleted files } {- $ENDIF} function DetectStringInFile (FName : string; { text file to check } SearchString : string; { string to be searched for } IgnoreCase : boolean; { TRUE: ignore case during search } MaxLength : integer) { max. length to search in the file } : integer; { position of search sString } function DirEmpty (DirName : string) { directory name to be checked } : boolean; { TRUE if directory is empty or non-existing } function DirExists (DirName : string) { directory name to be checked } : Boolean; { TRUE is directory exists } function DirIsReadOnly (Dir : string) { directory to be tested } : boolean; { returns true if dir is readonly } function DiskIsReadOnly (Drive : byte) { drive to be tested; 0=A:, 1=B:, 2=C:, ... } : boolean; { returns TRUE if disk cannot be written } procedure EnsureCRLFInFile (SrcFName, { source file name } DestFName : string); { destination file name } function EnsureDefaultFileExt (FName, { filename } Ext : string) { default file extension } : string; { filename having guaranteed file extension } function FileDetect (FileMask : string) { search name } : string; { full file name } function FindFirstMatchInTextFile (FName : string; { filename } SearchExp : string; { search expression } IgnoreCase : boolean; { TRUE: ignore case during search } var MatchedLine : string) { matched line } : integer; { position of 1st matched character } function GetFileSize (FileName : string) { file name to be checked } : Longint; { file size in bytes } function GetProgAssoc (FileExt : string) { file extension } : string; { associated program } function InsertBeforeFileExt (SubString, { substring to be inserted } FName : string) { file name } : string; { filename with the substring inserted } function InventPassword (NrChars : integer) { number of characters of password } : string; overload; { easily readable password } function InventPassword (NrChars : integer; { number of characters of password } MixCases : boolean; { TRUE: pwd contains lower/upper case chars } SpecChars : boolean) { TRUE: password contains special chars } : string; overload; { easily readable password } function IsRootDir (path : string) { directory to be tested } : boolean; { returns TRUE is path is root directory } function ParentDir (path : string) { directory } : string; { parent directory } function ReadLastNLinesOfTextFile (const FVar : TextFile; { text file to be read } NLines : integer; { number of lines to be returned } var Count : integer) { total number of lines in file } : TStrArray; overload; { array of the last NLines lines } function ReadLastNLinesOfTextFile (const FName : string; { filename } NLines : integer; { number of lines to be returned } var Count : integer) { total number of lines in file } : TStrArray; overload; { array of the last NLines lines } function ReadNextWordInTextFile (const FVar : Textfile) { text file to be read } : string; { next non-blank string } procedure ScanFilesToStrList (FileMask : string; { filemask of files to be included } SubDirs : boolean; { TRUE: recursive search in subdirectories } SL : TStringList; { string list to be filled } Feedback : TScanFilesFeedback); { feedback during scan process } {$IFNDEF DOTNET} procedure SetAllFilenameCase (FileMask : string; { filemask of files to process } Upc : boolean); { upper/lower case } {$ENDIF} function StripExtension (FName : string) { file name } : string; { name without extension } function StripPath (FName : string) { file name } : string; { name without path } {$IFDEF MSWINDOWS} {$IFNDEF DOTNET} procedure CopyFileTree (source, { path to root of source tree } dest : string; { path to destination tree } RemoveReadOnly : boolean; { TRUE: remove readonly flags } FeedBack : TTreeCopyFeedback); { feedback during copy process } {$IFDEF DELPHI} function DiskFreeExtended (Drive : Byte) { drive to be tested; 0=A:, 1=B:, 2=C:, ... } : comp; { number of free bytes } {$ENDIF} {$ENDIF} function DOSToWinPath (DOSPath : string) { DOS 8.3 path name } : string; { long Win32 path name } function IsDOS83Path (Path : string) { path to be checked } : boolean; { TRUE if path is DOS compatible } function ExtractDrive (Path : string) { path to be checked } : integer; { drive number } function GetEnviroVar (VarName : string) { environment variable } : string; { value of environment variable } function GetSystemDir : string; { returns system directory } function GetTempDir : string; { returns temporary directory } {$IFNDEF DOTNET} function FileCopyFeedBk (SourceName, { name of source file } DestName : string; { destination file name } RemoveReadOnly : boolean; { TRUE: remove readonly flags } FeedbackProc : TFileCopyFeedBack) { feedback during copy process } : integer; { error number } function GetDiskDriveType (Drive : byte) { drive to be tested; 0=A:, 1=B:, 2=C:, ... } : integer; { status of tested drive } function GetWindowsDir : string; { returns windows directory } function MoveToRecycleBin (FileMask : String) { filemask of files to move to recycle bin } : integer; { number of moved files } {$ENDIF} {$ENDIF} function ReadHeaderOfASC (FName : string; { name of ASC file to be read } var Comment : string; { comment line of header } var NFeat, { number of features } NObj : integer; { number of objects } var ClInf, { TRUE if class info is included } NamFeat, { TRUE if names are included } NamObj, { TRUE if object names are included } NominalVars : boolean) { TRUE if nominal variables are included } : integer; overload; { error number } function ReadHeaderOfASC (InStream : TStream; { stream to be read } var Comment : string; { comment line of header } var NFeat, { number of features } NObj : integer; { number of objects } var ClInf, { TRUE if class info is included } NamFeat, { TRUE if names are included } NamObj, { TRUE if object names are included } NominalVars : boolean) { TRUE if nominal variables are included } : integer; overload; { error number }
|