Browse Source

* Added ImplicitCurrentDir : Boolean = True parameter to FileSearch

git-svn-id: trunk@12946 -
joost 16 years ago
parent
commit
2c7d05d210
2 changed files with 7 additions and 5 deletions
  1. 1 1
      rtl/objpas/sysutils/filutilh.inc
  2. 6 4
      rtl/objpas/sysutils/sysutils.inc

+ 1 - 1
rtl/objpas/sysutils/filutilh.inc

@@ -95,7 +95,7 @@ Function FileGetAttr (Const FileName : String) : Longint;
 Function FileSetAttr (Const Filename : String; Attr: longint) : Longint;
 Function DeleteFile (Const FileName : String) : Boolean;
 Function RenameFile (Const OldName, NewName : String) : Boolean;
-Function FileSearch (Const Name, DirList : String) : String;
+Function FileSearch (Const Name, DirList : String; ImplicitCurrentDir : Boolean = True) : String;
 Function FileIsReadOnly(const FileName: String): Boolean;
 
 Function GetFileHandle(var f : File):Longint;

+ 6 - 4
rtl/objpas/sysutils/sysutils.inc

@@ -18,18 +18,18 @@
   { variant error codes }
   {$i varerror.inc}
 
-    Function FileSearch (Const Name, DirList : String) : String;
+    Function FileSearch (Const Name, DirList : String; ImplicitCurrentDir : Boolean = True) : String;
     Var
       I : longint;
       Temp : String;
 
     begin
-      // Start with checking the file in the current directory
       Result:=Name;
       temp:=SetDirSeparators(DirList);
+      // Start with checking the file in the current directory
+      If ImplicitCurrentDir and (Result <> '') and FileExists(Result) Then
+        exit;
       while True do begin
-        If (Result <> '') and FileExists(Result) Then
-          exit;
         If Temp = '' then
           Break; // No more directories to search - fail
         I:=pos(PathSeparator,Temp);
@@ -45,6 +45,8 @@
           end;
         If Result<>'' then
           Result:=IncludeTrailingPathDelimiter(Result)+name;
+        If (Result <> '') and FileExists(Result) Then
+          exit;
       end;
       result:='';
     end;