From 6bbdc985ba376a6c61c456ab2c7c9de023d46587 Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 12 May 2010 22:55:36 +0200 Subject: [PATCH] Added & fixed GetFiles/GetDirectories. --- Units/MMLAddon/PSInc/Wrappers/file.inc | 15 +++++++++++++++ Units/MMLAddon/PSInc/psexportedmethods.inc | 3 +++ Units/MMLCore/files.pas | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Units/MMLAddon/PSInc/Wrappers/file.inc b/Units/MMLAddon/PSInc/Wrappers/file.inc index bff5a67..f8e3dee 100644 --- a/Units/MMLAddon/PSInc/Wrappers/file.inc +++ b/Units/MMLAddon/PSInc/Wrappers/file.inc @@ -81,6 +81,21 @@ begin result := CreateDir(directoryName); end; +function ps_ForeDirectores(const dir : string) : boolean; extdecl; +begin + result := ForceDirectories(dir); +end; + +function ps_GetFiles(const Path, Ext : string) : TStringArray;extdecl; +begin + result := GetFiles(path,ext); +end; + +function ps_GetDirectories(const path : string) : TStringArray;extdecl; +begin + result := GetDirectories(path); +end; + procedure ps_WriteINI(const Section, KeyName, NewString, FileName: string);extdecl; var tempini : TIniFile; diff --git a/Units/MMLAddon/PSInc/psexportedmethods.inc b/Units/MMLAddon/PSInc/psexportedmethods.inc index d8f34b0..8854978 100644 --- a/Units/MMLAddon/PSInc/psexportedmethods.inc +++ b/Units/MMLAddon/PSInc/psexportedmethods.inc @@ -111,6 +111,9 @@ AddFunction(@ps_FilePointerPos, 'function FilePointerPos(FileNum: Integer): Inte AddFunction(@ps_DirectoryExists,'function DirectoryExists(const DirectoryName : string ) : Boolean;'); AddFunction(@ps_CreateDirectory,'function CreateDirectory(const DirectoryName : string) : boolean;'); AddFunction(@ps_FileExists,'function FileExists (const FileName : string ) : Boolean;'); +AddFunction(@ps_ForeDirectores,'function ForeDirectores(const dir : string) : boolean;'); +AddFunction(@ps_GetFiles,'function GetFiles(const Path, Ext : string) : TStringArray;'); +AddFunction(@ps_GetDirectories,'function GetDirectories(const path : string) : TStringArray;'); AddFunction(@ps_WriteINI,'procedure WriteINI(const Section, KeyName, NewString, FileName: string);'); AddFunction(@ps_ReadINI,'function ReadINI(const Section, KeyName, FileName: string): string;'); AddFunction(@ps_DeleteINI,'procedure DeleteINI(const Section, KeyName, FileName: string);'); diff --git a/Units/MMLCore/files.pas b/Units/MMLCore/files.pas index 21d7224..3596151 100644 --- a/Units/MMLCore/files.pas +++ b/Units/MMLCore/files.pas @@ -82,6 +82,8 @@ begin if FindFirst(Path + '*.' + ext, faAnyFile, SearchRec) = 0 then begin repeat + if (SearchRec.Attr and faDirectory) = faDirectory then + Continue; inc(c); SetLength(Result,c); Result[c-1] := SearchRec.Name; @@ -99,7 +101,7 @@ begin if FindFirst(Path + '*', faDirectory, SearchRec) = 0 then begin repeat - if SearchRec.Name[1] = '.' then + if (SearchRec.Name[1] = '.') or ((SearchRec.Attr and faDirectory) <> faDirectory) then continue; inc(c); SetLength(Result,c);