Jelajahi Sumber

* allow trailing backslash in SetCurrentDir and ChDir

git-svn-id: trunk@26550 -
Tomas Hajny 11 tahun lalu
induk
melakukan
daa8eadb14
2 mengubah file dengan 19 tambahan dan 3 penghapusan
  1. 14 2
      rtl/emx/sysdir.inc
  2. 5 1
      rtl/os2/sysdir.inc

+ 14 - 2
rtl/emx/sysdir.inc

@@ -106,6 +106,8 @@ begin
        if Len > 2 then
         begin
          DoDirSeparators (S);
+         if (S [Len] = DirectorySeparator) and (Len <> 3) then
+          S [Len] := #0;
          RC := DosSetCurrentDir (pchar(S));
          if RC <> 0 then
           begin
@@ -117,6 +119,8 @@ begin
     else
      begin
       DoDirSeparators (S);
+      if (Len > 1) and (S [Len] = DirectorySeparator) then
+       S [Len] := #0;
       RC := DosSetCurrentDir (pchar(S));
       if RC <> 0 then
        begin
@@ -144,14 +148,22 @@ begin
 @LCHDIR:
      end ['eax','edx','esi'];
      if (Len > 2) and (InOutRes <> 0) then
+      begin
+       if (S [Len] in AllowDirectorySeparators) and (Len <> 3) then
+        S [Len] := #0;
       { Under EMX 0.9d DOS this routine may sometime }
       { fail or crash the system.                    }
-      DosDir ($3B, S);
+       DosDir ($3B, S);
+      end;
     end
    else
+    begin
+     if (Len > 1) and (S [Len] in AllowDirectorySeparators) then
+      S [Len] := #0;
     { Under EMX 0.9d DOS this routine may sometime }
     { fail or crash the system.                    }
-    DosDir ($3B, S);
+     DosDir ($3B, S);
+    end;
 end;
 
 

+ 5 - 1
rtl/os2/sysdir.inc

@@ -58,7 +58,7 @@ var RC: cardinal;
     Len: Longint;
 
 begin
-  Len := Length (s);
+  Len := Length (S);
   if (Len >= 2) and (S[2] = ':') then
   begin
     RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40);
@@ -68,6 +68,8 @@ begin
       if Len > 2 then
       begin
         DoDirSeparators (s);
+        if (S [Len] = DirectorySeparator) and (Len <> 3) then
+         S [Len] := #0;
         RC := DosSetCurrentDir (pchar (s));
         if RC <> 0 then
         begin
@@ -77,6 +79,8 @@ begin
       end;
   end else begin
     DoDirSeparators (s);
+    if (Len > 1) and (S [Len] = DirectorySeparator) then
+     S [Len] := #0;
     RC := DosSetCurrentDir (pchar (s));
     if RC <> 0 then
     begin