const
{$IFDEF PAIDVERS}
SDLVersionInfo = 'filesys_r1210_full';
IsLightEd = false;
{$ELSE}
SDLVersionInfo = 'filesys_r1210_lighted';
IsLightEd = true;
{$ENDIF}
Release = 1210;
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}
{$IFDEF GE_LEV29}
[ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidWin64x)]
{$ENDIF}
TUnivSaveDialog = class (TCommonDialog)
{$ELSE}
TUnivSaveDialog = class (TComponent)
{$ENDIF}
private
FParams : string;
FFileName : string;
FParentWnd : HWnd;
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;
property ParentWnd: HWnd read FParentWnd write FParentWnd;
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}
procedure ClearTextFile
(FName : string); { file name of text file }
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 DeleteRegKey
(RootKey : HKEY; { root key }
SubKey : string) { key to be cleared }
: boolean; { TRUE if success }
function DeleteRegValue
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be deleted }
: boolean; { TRUE if success }
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 FilterCopyTextFile
(InFName, { file to be processed }
OutFName : string; { resulting file }
SuppressedLines : TIntArray) { list of lines to be suppressed }
: integer; { error number }
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 GetAllRegSubkeys
(RootKey : HKEY; { root key }
RegKey : string; { key for which the subkeys are sought }
SubKeys : TStringList) { list of defined subkeys in RegKey }
: integer; { number of found subkeys }
function GetAllRegValueNames
(RootKey : HKEY; { root key }
RegKey : string; { subkey for which the value names are sought }
ValueNames : TStringList) { list of defined value names in RegKey }
: integer; { number of found value names }
function GetRegValue
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be deleted }
: string; { read value }
function GetRegValueAsInt
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be deleted }
: integer; { read value }
function GetRegValueAsDouble
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be deleted }
: double; { read value }
function GetRegValueAsBoolean
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be deleted }
: boolean; { read value }
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 IsValidFileName
(FName : string) { filename to be tested }
: boolean; { TRUE if filename is valid }
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 PathDiff
(path1, path2 : string) { pathes to be compared }
: string; { difference of pathes }
function ReadStringFromTextFile
(FName : string; { filename }
StartTrigger, { start trigger word }
EndTrigger : string) { end trigger word }
: string; { read string }
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 }
function RegKeyExists
(RootKey : HKEY; { root key }
SubKey : string) { key to be ckecked }
: boolean; { TRUE if key exists }
function RegValueExists
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string) { value to be checked }
: boolean; { TRUE if value exists }
function ReplaceInvalidFileNameChars
(FName : string; { filename to be processed }
ReplacementChar : char) { replacement character }
: string; { processed filename }
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}
procedure SetRegValue
(RootKey : HKEY; { root key }
SubKey : string; { subkey where value is stored }
ValueID : string; { name of value }
Value : string); { value }
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 IsFN83CompliantPath
(Path : string) { path to be checked }
: boolean; { TRUE if Windows filename 8.3 compliant }
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 }
{$IFDEF GE_LEV25}
// the following function are only available from RadStudio 10.2 Tokyo upwards
function DateTimeToFileTime
(DateTimeUTC : TDateTime)
: TFileTime;
function FileTimeToDateTime
(FileTime : TFileTime)
: TDateTime;
function GetFileDates
(FName : string;
var CreationDate,
LastAccessDate,
LastWriteDate : TDateTime)
: integer;
function GetMacAddress
(Adapter : integer; { adapter type }
var MacAddress : string) { MAC address }
: integer; { error code }
function GetMemoryStatus
(var TotalMem, { total memory in bytes }
AvailableMem : Int64) { available memory in bytes }
: boolean; { TRUE: returned values are valid }
function GetMemoryUsed
: UInt64; { amount of memory used by the current process }
function SetFileDates
(FName : string;
CreationDate,
LastAccessDate,
LastWriteDate : TDateTime)
: integer;
{$ENDIF}
|