Allow snippet files with more than one dot. Fixes issue #2264. Also, this removes GetFilesFromDir() and makes use of TDirectory.GetFiles instead.

This commit is contained in:
Ansgar Becker
2011-01-19 20:47:37 +00:00
parent 0911c8edad
commit 58a95bc978
2 changed files with 22 additions and 47 deletions

View File

@ -101,7 +101,6 @@ type
procedure debug(txt: String);
function fixNewlines(txt: String): String;
function GetShellFolder(CSIDL: integer): string;
function GetFilesFromDir( dir: String; pattern: String = '*.*'; hideExt: Boolean = false ): TStringList;
function goodfilename( str: String ): String;
function FormatNumber( str: String; Thousands: Boolean=True): String; Overload;
function UnformatNumber(Val: String): String;
@ -1077,38 +1076,6 @@ end;
{***
Return all files in a given directory into a TStringList
@param string Folderpath
@param string Filepattern to filter files, defaults to all files (*.*)
@return TStringList Filenames
}
function GetFilesFromDir( dir: String; pattern: String = '*.*'; hideExt: Boolean = false ): TStringList;
var
sr : TSearchRec;
s : String;
begin
result := TStringList.Create;
if dir[length(dir)] <> '\' then
dir := dir + '\';
if FindFirst( dir + pattern, $3F, sr ) = 0 then
begin
repeat
if (sr.Attr and faAnyFile) > 0 then begin
s := sr.Name;
if hideExt and (Pos('.', s) > 0) then begin
SetLength(s, Pos('.', s) - 1);
end;
result.Add( s );
end;
until FindNext( sr ) <> 0;
// FindClose( sr );
end;
end;
{***
Remove special characters from a filename