Browse Source

* Improve TPath initialization

(cherry picked from commit 77ade8b74f845ecc6ea1cdca5d9ce3df4537527b)
Michaël Van Canneyt 2 years ago
parent
commit
569fa5f0b2
1 changed files with 12 additions and 8 deletions
  1. 12 8
      packages/vcl-compat/src/system.ioutils.pp

+ 12 - 8
packages/vcl-compat/src/system.ioutils.pp

@@ -385,16 +385,20 @@ begin
 { TPath }
 
 class constructor TPath.Create;
+var
+  C : Char;
 begin
-  FAltDirectorySeparatorChar:='/';
-  FExtensionSeparatorChar   :=system.ExtensionSeparator;
-  FDirectorySeparatorChar   :=system.DirectorySeparator;
-  FPathSeparator            :=system.PathSeparator;
-  {$IfDef MSWINDOWS}
-    FVolumeSeparatorChar    :=':';
-  {$Else}
+  FAltDirectorySeparatorChar:=#0;;
+  For C in AllowDirectorySeparators do
+    if (C<>System.DirectorySeparator) and (FAltDirectorySeparatorChar=#0) then
+      FAltDirectorySeparatorChar:=C;
+  FExtensionSeparatorChar   := System.ExtensionSeparator;
+  FDirectorySeparatorChar   := System.DirectorySeparator;
+  FPathSeparator            := System.PathSeparator;
+  if Length(DriveSeparator)>0 then
+    FVolumeSeparatorChar     := DriveSeparator[1]
+  else
     FVolumeSeparatorChar    :=#0;
-  {$EndIf}
 end;
 
 class function TPath.IsValidPathChar(const AChar: Char): Boolean;