diff --git a/components/codetools/definetemplates.pas b/components/codetools/definetemplates.pas index 92b192fbd0..98dbc01d1c 100644 --- a/components/codetools/definetemplates.pas +++ b/components/codetools/definetemplates.pas @@ -3050,7 +3050,8 @@ var if FindFirst(ADirPath+FileMask,faAnyFile,FileInfo)=0 then begin repeat AFilename:=FileInfo.Name; - if (AFilename='.') or (AFilename='..') then continue; + if (AFilename='') or (AFilename='.') or (AFilename='..') then + continue; //debugln('Browse Filename=',AFilename,' IsDir=',(FileInfo.Attr and faDirectory)>0); i:=High(IgnoreDirs); while (i>=Low(IgnoreDirs)) and (AFilename<>IgnoreDirs[i]) do dec(i); diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index b2b78aaf12..b0b4bb632a 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -683,7 +683,9 @@ function TStandardCodeTool.FixUnitInFilenameCaseInUsesSection( begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then + continue; if (SysUtils.CompareText(CurFilename,FileInfo.Name)=0) then begin if (Result='') or (FileInfo.Name=CurFilename) then diff --git a/components/projecttemplates/projecttemplates.pp b/components/projecttemplates/projecttemplates.pp index ccef021402..5df0f9bec4 100644 --- a/components/projecttemplates/projecttemplates.pp +++ b/components/projecttemplates/projecttemplates.pp @@ -203,7 +203,7 @@ begin try Repeat If ((Info.Attr and faDirectory)<>0) - and not ((Info.Name='.') or (Info.Name='..')) then + and not ((Info.Name='.') or (Info.Name='..') or (Info.Name='')) then With Add as TProjectTemplate do InitFromDir(D+Info.Name); Until FindNext(Info)<>0; @@ -400,7 +400,7 @@ begin try repeat if ((Info.attr and faDirectory)<>0) and - (Info.Name<>'.') and (info.Name<>'..') then + (Info.Name<>'.') and (info.Name<>'..') and (Info.Name<>'') then GetFileList(Dir+Info.Name+PathSeparator); until FindNext(Info)<>0; finally @@ -435,8 +435,9 @@ begin try repeat if ((Info.attr and faDirectory)<>0) and - (Info.Name<>'.') and (info.Name<>'..') then - CopyAndSubstituteDir(D1+Info.Name,D2+SubstituteString(Info.Name,Values),Values); + (Info.Name<>'.') and (info.Name<>'..') and (Info.Name<>'') + then + CopyAndSubstituteDir(D1+Info.Name,D2+SubstituteString(Info.Name,Values),Values); until FindNext(Info)<>0; finally FindClose(Info); diff --git a/examples/codepageconverter/filefind/filefind.pas b/examples/codepageconverter/filefind/filefind.pas index 2aa50d34ca..26b21dad01 100644 --- a/examples/codepageconverter/filefind/filefind.pas +++ b/examples/codepageconverter/filefind/filefind.pas @@ -238,7 +238,7 @@ var var dirq : TSearchRec; begin - if assigned(fChangeFolderEvent) then + if assigned(fChangeFolderEvent) then fChangeFolderEvent(fullpath,FolderInfo); doserror := findfirst(fullpath+sfi,attr,dirq); diff --git a/examples/codepageconverter/mainunit.pas b/examples/codepageconverter/mainunit.pas index 7cdbb1d9ff..544a848b04 100644 --- a/examples/codepageconverter/mainunit.pas +++ b/examples/codepageconverter/mainunit.pas @@ -246,8 +246,10 @@ begin if FindFirst(directory + msk, faDirectory, search) = 0 then begin repeat - if ((search.Attr and faDirectory) = faDirectory) and (search.Name[1] <> '.') then - GetAllFiles(directory + search.Name + delimeter + ExtractFileName(mask),unignore,subdirs); + if ((search.Attr and faDirectory) = faDirectory) + and (search.Name[1] <> '.') and (search.Name<>'') then + GetAllFiles(directory + search.Name + delimeter + ExtractFileName(mask), + unignore,subdirs); until FindNext(search) <> 0; FindClose(search); end; diff --git a/examples/imgviewer/frmmain.pas b/examples/imgviewer/frmmain.pas index e5f65f1f0a..1cf8ca80a3 100644 --- a/examples/imgviewer/frmmain.pas +++ b/examples/imgviewer/frmmain.pas @@ -234,8 +234,7 @@ begin if FindFirst(Directory+'*',faDirectory,Info)=0 then try Repeat - If (Info.Name<>'.') and - (info.name<>'..') and + If (Info.Name<>'.') and (Info.Name<>'') and (info.name<>'..') and ((Info.Attr and faDirectory)<>0) then AddDir(Directory+Info.name,True); until (FindNext(Info)<>0) diff --git a/ide/cleandirdlg.pas b/ide/cleandirdlg.pas index 1aa2b265fb..e8164991fa 100644 --- a/ide/cleandirdlg.pas +++ b/ide/cleandirdlg.pas @@ -283,7 +283,8 @@ var then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then continue; FullFilename:=MainDirectory+FileInfo.Name; if (FileInfo.Attr and faDirectory)>0 then begin if SubDirsCheckbox.Checked then begin diff --git a/ide/frmsearch.pas b/ide/frmsearch.pas index 47bc99fd15..e831f7b158 100644 --- a/ide/frmsearch.pas +++ b/ide/frmsearch.pas @@ -394,7 +394,7 @@ begin begin repeat // check if special file, skip directories this time - if (FileInfo.Name='.') or (FileInfo.Name='..') + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') or ((faDirectory and FileInfo.Attr)>0) then continue; //Make sure this is a text file as it will be searched if FileIsReadable(TempDir + FileInfo.Name) @@ -425,7 +425,9 @@ begin // check if directory and not special file if ((faDirectory and FileInfo.Attr)>0) and (FileInfo.Name<>'.') and (FileInfo.Name<>'..') - then DoFindInFiles(TempDir + FileInfo.Name); + and (FileInfo.Name<>'') + then + DoFindInFiles(TempDir + FileInfo.Name); if fAbort and not fAborting then begin fAborting:= True; diff --git a/ide/ideprocs.pp b/ide/ideprocs.pp index 9ebe9793bb..5e38707295 100644 --- a/ide/ideprocs.pp +++ b/ide/ideprocs.pp @@ -261,7 +261,8 @@ begin then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then + continue; if (AnsiCompareText(CaseInsensitiveFilename,FileInfo.Name)=0) and ((not IgnoreExact) or (CompareFilenames(CaseInsensitiveFilename,FileInfo.Name)<>0)) @@ -297,7 +298,8 @@ begin ShortFilename:=ExtractFilename(Filename); repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then + continue; if CompareFilenames(ShortFilename,FileInfo.Name)=0 then begin Result:=FileInfo.Name; break; @@ -749,7 +751,8 @@ begin then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then + continue; // check extension if CompareFileExt(FileInfo.Name,Ext,false)=0 then begin Result:=AppendPathDelim(Directory)+FileInfo.Name; @@ -1967,7 +1970,8 @@ var if SysUtils.FindFirst(CurSrcDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then continue; CurFilename:=CurSrcDir+FileInfo.Name; // check if src file if FilenameIsMatching(DestDirectory,CurFilename,false) then continue; diff --git a/ide/main.pp b/ide/main.pp index e6a6bb4880..c0ee8ea953 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -10242,7 +10242,9 @@ var end; repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then + continue; CurFilename:=CurDirectory+FileInfo.Name; if FileIsText(CurFilename) then Files.Add(CurFilename); diff --git a/ide/mainbase.pas b/ide/mainbase.pas index c1b290557b..f197280c1c 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -968,6 +968,7 @@ begin UnitName:=ExtractFilenameOnly(ShortFilename); repeat if (FileInfo.Name='.') or (FileInfo.Name='..') + or (FileInfo.Name='') or ((FileInfo.Attr and faDirectory)<>0) then continue; if (ShortFilename=FileInfo.Name) then continue; if (AnsiCompareText(ShortFilename,FileInfo.Name)<>0) @@ -1069,7 +1070,7 @@ begin FileInfoNeedClose:=true; if SysUtils.FindFirst(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin repeat - if (FileInfo.Name='.') or (FileInfo.Name='..') + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') or ((FileInfo.Attr and faDirectory)<>0) then continue; if FilenameIsPascalUnit(FileInfo.Name) then CurUnitTree:=SourceUnitTree diff --git a/ide/translations.pas b/ide/translations.pas index d10dd9a6a6..e5ee7cc087 100644 --- a/ide/translations.pas +++ b/ide/translations.pas @@ -180,6 +180,8 @@ begin if SysUtils.FindFirst(SearchMask,faAnyFile,FileInfo)=0 then begin repeat + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then continue; ID:=copy(FileInfo.Name,length('lazaruside.')+1, length(FileInfo.Name)-length('lazaruside..po')); //writeln('CollectTranslations A ',FileInfo.Name,' ID=',ID); diff --git a/lcl/dirsel.pas b/lcl/dirsel.pas index ddcfc7579a..0b9ac93d03 100644 --- a/lcl/dirsel.pas +++ b/lcl/dirsel.pas @@ -97,7 +97,7 @@ begin begin repeat // check if special file - if ((FileInfo.Name='.') or (FileInfo.Name='..')) or + if ((FileInfo.Name='.') or (FileInfo.Name='..')) or (FileInfo.Name='') (((faHidden and FileInfo.Attr)>0) and IgnoreHidden) then continue; Result:= ((faDirectory and FileInfo.Attr)>0); @@ -136,7 +136,9 @@ begin SortList.Sorted:= True; repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then + continue; // if this is a directory then add it to the tree. if ((faDirectory and FileInfo.Attr)>0) then begin diff --git a/lcl/include/fileutil.inc b/lcl/include/fileutil.inc index c551417b0f..72b58d421f 100644 --- a/lcl/include/fileutil.inc +++ b/lcl/include/fileutil.inc @@ -750,7 +750,8 @@ begin if SysUtils.FindFirst(CurSrcDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then + continue; CurFilename:=CurSrcDir+FileInfo.Name; if (FileInfo.Attr and faDirectory)>0 then begin if not DeleteDirectory(CurFilename,false) then exit; diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index cf4c4f1fcd..809953abc6 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -3331,7 +3331,7 @@ begin then repeat if ((Info.Attr and faDirectory) = faDirectory) and (Info.Name <> '.') - and (Info.Name <> '..') then + and (Info.Name <> '..') and (Info.Name<>'') then StrList.Add(AppendPathDelim(Info.Name)); until FindNext(Info) <> 0; FindClose(Info); diff --git a/packager/packagedefs.pas b/packager/packagedefs.pas index 2919a1b11b..65fd8f5639 100644 --- a/packager/packagedefs.pas +++ b/packager/packagedefs.pas @@ -2778,7 +2778,8 @@ var then begin repeat // check if special file - if (FileInfo.Name='.') or (FileInfo.Name='..') then continue; + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') + then continue; Result.Add(FileInfo.Name); //debugln('AddDirectoryListing ',FileInfo.Name); until SysUtils.FindNext(FileInfo)<>0; diff --git a/tools/updatepofiles.pas b/tools/updatepofiles.pas index 124364458a..63992fa5d1 100644 --- a/tools/updatepofiles.pas +++ b/tools/updatepofiles.pas @@ -326,7 +326,7 @@ begin NameOnly:=LeftStr(Name,length(Name)-length(Ext)); if SysUtils.FindFirst(Path+FindMask,faAnyFile,FileInfo)=0 then begin repeat - if (FileInfo.Name='.') or (FileInfo.Name='..') + if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') or (CompareFilenames(FileInfo.Name,Name)=0) then continue; CurExt:=ExtractFileExt(FileInfo.Name); if (CompareFilenames(CurExt,'.po')<>0)