Browse Source

* Cleaned up the work of two days using the rawbytestring alias for 2.6.2 bootstrapping.

git-svn-id: branches/unicode@24772 -
marco 12 years ago
parent
commit
1567e63420

+ 16 - 2
rtl/inc/dos.inc

@@ -286,7 +286,6 @@ end;
 
 {$ENDIF HAS_FEXPAND}
 
-{$ifdef FPC_UNICODE_RTL}
 procedure getdir(drivenr:byte;var dir: pathstr);
 var s : ansistring;
 begin
@@ -294,4 +293,19 @@ begin
    system.getdir(drivenr,s);
    dir:=s;
 end;
-{$endif}
+
+Procedure MkDir(Const s: String);
+Begin
+  system.mkdir(ansistring(s));
+End;
+
+Procedure RmDir(Const s: String);
+Begin
+  system.rmdir(ansistring(s));
+End;
+
+Procedure ChDir(Const s: String);
+Begin
+  system.chdir(ansistring(s));
+End;
+

+ 5 - 2
rtl/inc/dosh.inc

@@ -145,6 +145,9 @@ Function  GetMsCount: int64;
  particular meaning - it can be e.g. amount of milliseconds since computer
  startup on DOS-like x86 platforms, derived from Unix time on Unix etc.}
 
-{$ifdef FPC_UNICODE_RTL}
+// in 2.7.1+ all shortstring routines from system move to dos.
+Procedure chdir(const s:string);
+Procedure mkdir(const s:string);
+Procedure rmdir(const s:string); overload;
 procedure GetDir(Drivenr:Byte;var Dir: PathStr);
-{$endif}
+

+ 5 - 64
rtl/inc/file.inc

@@ -35,7 +35,7 @@ Begin
   InitFile(F);
   FileRec(f).Name:=Name;
 End;
-
+{$endif}
 Procedure Assign(out f:File;const Name: RawByteString);
 {
   Assign Name to file f so it can be used with the file routines
@@ -44,24 +44,6 @@ Begin
   InitFile(F);
   FileRec(f).Name:=Name;
 End;
-{$ELSE}
-
-Procedure Assign(out f:File;p:pchar);
-begin
-  Assign(f,StrPas(p));
-end;
-
-Procedure Assign(out f:File;c:char);
-begin
-  Assign(f,string(c));
-end;
-
-Procedure Assign(out f:File;const Name:string);
-Begin
-  initfile(f);
-  Move(Name[1],FileRec(f).Name,Length(Name));
-End;
-{$ENDIF}
 
 Procedure Rewrite(var f:File;l:Longint);[IOCheck];
 {
@@ -87,7 +69,7 @@ Begin
 {$IFDEF FPC_UNICODE_RTL}
      Do_Open(f,UnicodeString(FileRec(f).Name),$1002);
 {$ELSE}
-     Do_Open(f,PChar(@FileRec(f).Name),$1002);
+     Do_Open(f,(FileRec(f).Name),$1002);
 {$ENDIF}
      FileRec(f).RecSize:=l;
    End;
@@ -117,7 +99,7 @@ Begin
 {$IFDEF FPC_UNICODE_RTL}
      Do_Open(f,UnicodeString(FileRec(f).Name),Filemode);
 {$ELSE}
-     Do_Open(f,PChar(@FileRec(f).Name),FileMode);
+     Do_Open(f,(FileRec(f).Name),FileMode);
 {$ENDIF}
      FileRec(f).RecSize:=l;
    End;
@@ -409,7 +391,7 @@ Begin
 {$IFDEF FPC_UNICODE_RTL}
    Do_Erase(UnicodeString(FileRec(f).Name));
 {$ELSE}
-   Do_Erase(pchar(@FileRec(f).Name));
+   Do_Erase(FileRec(f).Name);
 {$ENDIF}
 End;
 
@@ -424,7 +406,7 @@ Begin
   If InOutRes = 0 then
      FileRec(f).Name:=S
 End;
-
+{$endif}
 
 Procedure Rename(var f : File;const s : rawbytestring);[IOCheck];
 
@@ -436,44 +418,3 @@ Begin
      FileRec(f).Name:=S
 End;
 
-{$ELSE}
-
-Procedure Rename(var f : File;p:pchar);[IOCheck];
-
-Begin
-  If InOutRes <> 0 then
-    exit;
-  If FileRec(f).mode=fmClosed Then
-    Begin
-    Do_Rename(PChar(@FileRec(f).Name),p);
-    { check error code of do_rename }
-    If InOutRes = 0 then
-      Move(p^,FileRec(f).Name,StrLen(p)+1);
-    End;
-End;
- 
- 
-Procedure Rename(var f : File;const s : string);[IOCheck];
-var
-  p : array[0..255] Of Char;
-Begin
-   If InOutRes <> 0 then
-    exit;
-  Move(s[1],p,Length(s));
-  p[Length(s)]:=#0;
-  Rename(f,Pchar(@p));
-End;
- 
- 
-Procedure Rename(var f : File;c : char);[IOCheck];
-var
-  p : array[0..1] Of Char;
-Begin
-  If InOutRes <> 0 then
-   exit;
-  p[0]:=c;
-  p[1]:=#0;
-  Rename(f,Pchar(@p));
-End;
-{$ENDIF}
-

+ 9 - 62
rtl/inc/system.inc

@@ -1484,63 +1484,35 @@ end;
 { OS dependent dir functions }
 {$i sysdir.inc}
 
-{$IFNDEF FPC_UNICODE_RTL}
-
-{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-Procedure getdir(drivenr:byte;Var dir:ansistring);
-
- { this is needed to also allow ansistrings, the shortstring version is
-   OS dependent }
-var
-  s : shortstring;
-begin
-  getdir(drivenr,s);
-  dir:=s;
-end;
+{$IFDEF FPC_UNICODE_RTL}
+// UNICODE Implementation
 
-{$endif}
-Procedure MkDir(Const s: String);
-Var
-  Buffer: Array[0..255] of Char;
+Procedure MkDir(Const s: UnicodeString);
 Begin
   If (s='') or (InOutRes <> 0) then
    exit;
-  Move(s[1], Buffer, Length(s));
-  Buffer[Length(s)] := #0;
-  do_MkDir(@buffer[0],length(s));
+  Do_mkdir(S);
 End;
 
-Procedure RmDir(Const s: String);
-Var
-  Buffer: Array[0..255] of Char;
+Procedure RmDir(Const s: UnicodeString);
 Begin
   If (s='') or (InOutRes <> 0) then
    exit;
-  Move(s[1], Buffer, Length(s));
-  Buffer[Length(s)] := #0;
-  do_RmDir(@buffer[0],length(s));
+  Do_rmdir(S);
 End;
 
-Procedure ChDir(Const s: String);
-Var
-  Buffer: Array[0..255] of Char;
-
+Procedure ChDir(Const s: UnicodeString);
 Begin
   If (s='') or (InOutRes <> 0) then
    exit;
-  Move(s[1], Buffer, Length(s));
-  Buffer[Length(s)] := #0;
-  do_ChDir(@buffer[0],length(s));
+  Do_chdir(S);
 End;
 
-{$ELSE}
-
-// UNICODE Implementation
-
 Procedure getdir(drivenr:byte;Var dir: unicodestring);
 begin
   do_getdir(drivenr,dir);
 end;
+{$endif}
 
 Procedure getdir(drivenr:byte;Var dir: rawbytestring);
 begin
@@ -1555,14 +1527,6 @@ Begin
   Do_mkdir(S);
 End;
 
-Procedure MkDir(Const s: UnicodeString);
-
-Begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
-  Do_mkdir(S);
-End;
-
 Procedure RmDir(Const s: RawByteString);
 
 Begin
@@ -1571,14 +1535,6 @@ Begin
   Do_rmdir(S);
 End;
 
-Procedure RmDir(Const s: UnicodeString);
-
-Begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
-  Do_rmdir(S);
-End;
-
 Procedure ChDir(Const s: RawByteString);
 
 Begin
@@ -1587,15 +1543,6 @@ Begin
   Do_chdir(S);
 End;
 
-Procedure ChDir(Const s: UnicodeString);
-
-Begin
-  If (s='') or (InOutRes <> 0) then
-   exit;
-  Do_chdir(S);
-End;
-{$ENDIF}
-
 {$ENDIF}
 
 {*****************************************************************************

+ 13 - 39
rtl/inc/systemh.inc

@@ -1043,19 +1043,12 @@ procedure SetMultiByteRTLFileSystemCodePage(CodePage: TSystemCodePage);
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-{$IFNDEF FPC_UNICODE_RTL}
-Procedure Assign(out f:File;const Name:string);
-Procedure Assign(out f:File;p:pchar);
-Procedure Assign(out f:File;c:char);
-Procedure Rename(var f:File;const s:string);
-Procedure Rename(var f:File;p:pchar);
-Procedure Rename(var f:File;c:char);
-{$ELSE}
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Assign(out f:File;const Name: UnicodeString);
-Procedure Assign(out f:File;const Name: RawByteString);
 Procedure Rename(var f:File;const s : UnicodeString);
+{$Endif}
+Procedure Assign(out f:File;const Name: RawByteString);
 Procedure Rename(var f:File;const s : RawByteString);
-{$ENDIF}
 Procedure Rewrite(var f:File;l:Longint);
 Procedure Rewrite(var f:File);
 Procedure Reset(var f:File;l:Longint);
@@ -1087,14 +1080,10 @@ Procedure Truncate (var F:File);
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-{$IFNDEF FPC_UNICODE_RTL}
-Procedure Assign(out f:TypedFile;const Name:string);
-Procedure Assign(out f:TypedFile;p:pchar);
-Procedure Assign(out f:TypedFile;c:char);
-{$ELSE}
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Assign(out f:TypedFile;const Name:unicodestring);
-Procedure Assign(out f:TypedFile;const Name:rawbytestring);
 {$ENDIF}
+Procedure Assign(out f:TypedFile;const Name:rawbytestring);
 Procedure Reset(var f : TypedFile);   [INTERNPROC: fpc_in_Reset_TypedFile];
 Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
 {$endif FPC_HAS_FEATURE_FILEIO}
@@ -1104,19 +1093,12 @@ Procedure Rewrite(var f : TypedFile); [INTERNPROC: fpc_in_Rewrite_TypedFile];
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
-{$IFNDEF FPC_UNICODE_RTL}
-Procedure Assign(out t:Text;const s:string);
-Procedure Assign(out t:Text;p:pchar);
-Procedure Assign(out t:Text;c:char);
-Procedure Rename(var t:Text;const s:string);
-Procedure Rename(var t:Text;p:pchar);
-Procedure Rename(var t:Text;c:char);
-{$ELSE}
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Assign(out t:Text;const s:unicodestring);
-Procedure Assign(out t:Text;const s:rawbytestring);
 Procedure Rename(var t:Text;const s:unicodestring);
+{$endif}
 Procedure Rename(var t:Text;const s:rawbytestring);
-{$ENDIF}
+Procedure Assign(out t:Text;const s:rawbytestring);
 Procedure Close(var t:Text);
 Procedure Rewrite(var t:Text);
 Procedure Reset(var t:Text);
@@ -1142,26 +1124,18 @@ procedure SetTextCodePage(var T: Text; CodePage: TSystemCodePage);
                             Directory Management
 ****************************************************************************}
 
-
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-{$IFNDEF FPC_UNICODE_RTL}
-Procedure chdir(const s:string); overload;
-Procedure mkdir(const s:string); overload;
-Procedure rmdir(const s:string); overload;
-Procedure getdir(drivenr:byte;var dir:shortstring);
-{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
-Procedure getdir(drivenr:byte;var dir:ansistring);
-{$endif FPC_HAS_FEATURE_ANSISTRINGS}
-{$ELSE}
+{$IFDEF FPC_UNICODE_RTL}
 Procedure chdir(const s:unicodestring); overload;
 Procedure mkdir(const s:unicodestring); overload;
 Procedure rmdir(const s:unicodestring); overload;
+Procedure getdir(drivenr:byte;var dir: unicodestring);
+{$endif}
+{$ifdef FPC_HAS_FEATURE_ANSISTRINGS}
 Procedure chdir(const s:rawbytestring); overload;
 Procedure mkdir(const s:rawbytestring); overload;
 Procedure rmdir(const s:rawbytestring); overload;
-
-Procedure getdir(drivenr:byte;var dir: unicodestring);
-Procedure getdir(drivenr:byte;var dir: rawbytestring);{$ifndef VER2_6}rtlproc; {$endif}// defaultrtlfilesystemcodepage is used here
+Procedure getdir(drivenr:byte;var dir: rawbytestring);{$ifdef FPC_HAS_CPSTRING}rtlproc;{$endif FPC_HAS_CPSTRING}// defaultrtlfilesystemcodepage is used here
 {$ENDIF}
 {$endif FPC_HAS_FEATURE_FILEIO}
 

+ 4 - 63
rtl/inc/text.inc

@@ -60,7 +60,7 @@ Begin
 {$IFDEF FPC_UNICODE_RTL}
   Do_Open(t,unicodestring(t.Name),Flags);
 {$ELSE FPC_UNICODE_RTL}
-  Do_Open(t,pchar(@t.Name),Flags);
+  Do_Open(t,(t.Name),Flags);
 {$ENDIF FPC_UNICODE_RTL}
   t.CloseFunc:=@FileCloseFunc;
   t.FlushFunc:=nil;
@@ -102,33 +102,12 @@ begin
   InitText(t);
   TextRec(t).Name:=S;
 end;
-
+{$endif}
 Procedure Assign(out t:Text;const s: RawByteString);
 Begin
   InitText(t);
   TextRec(t).Name:=S;
 End;
-{$ELSE}
-
-Procedure Assign(out t:Text;const s:String);
-Begin
-  InitText(T);
-  Move(s[1],TextRec(t).Name,Length(s));
-end;
-
-Procedure Assign(out t:Text;p:pchar);
-begin
-  Assign(t,StrPas(p));
-  InitText(t);
-end;
-
-Procedure Assign(out t:Text;c:char);
-begin
-  Assign(t,string(c));
-end;
-
-{$ENDIF}
-
 
 Procedure Close(var t : Text);[IOCheck];
 Begin
@@ -233,7 +212,7 @@ Begin
 {$IFDEF FPC_UNICODE_RTL}
    Do_Erase(unicodestring(TextRec(t).Name));
 {$ELSE FPC_UNICODE_RTL}
-   Do_Erase(@TextRec(t).Name);
+   Do_Erase(TextRec(t).Name);
 {$ENDIF FPC_UNICODE_RTL}
 End;
 
@@ -248,6 +227,7 @@ Begin
   if InoutRes=0 then
     TextRec(T).Name:=S;
 End;
+{$endif}
 
 Procedure Rename(var t : Text;const s : rawbytestring);[IOCheck];
 Begin
@@ -258,45 +238,6 @@ Begin
     TextRec(T).Name:=S;
 End;
 
-{$ELSE FPC_UNICODE_RTL}
-
-Procedure Rename(var t : text;p:pchar);[IOCheck];
-Begin
-  If InOutRes <> 0 then
-   exit;
-  If TextRec(t).mode=fmClosed Then
-   Begin
-     Do_Rename(PChar(@TextRec(t).Name),p);
-     { check error code of do_rename }
-     If InOutRes = 0 then
-         Move(p^,TextRec(t).Name,StrLen(p)+1);
-   End;
-End;
-
-Procedure Rename(var t : Text;const s : string);[IOCheck];
-var
-  p : array[0..255] Of Char;
-Begin
-  If InOutRes <> 0 then
-   exit;
-  Move(s[1],p,Length(s));
-  p[Length(s)]:=#0;
-  Rename(t,Pchar(@p));
-End;
-
-Procedure Rename(var t : Text;c : char);[IOCheck];
-var
-  p : array[0..1] Of Char;
-Begin
-  If InOutRes <> 0 then
-    exit;
-  p[0]:=c;
-  p[1]:=#0;
-  Rename(t,Pchar(@p));
-End;
-
-{$ENDIF FPC_UNICODE_RTL}
-
 Function Eof(Var t: Text): Boolean;[IOCheck];
 Begin
   If (InOutRes<>0) then

+ 1 - 24
rtl/inc/typefile.inc

@@ -32,6 +32,7 @@ Begin
   InitTypedFile(F);
   FileRec(f).Name:=Name;
 End;
+{$endif}
 
 Procedure Assign(out f:TypedFile;const Name: rawbytestring);
 {
@@ -41,30 +42,6 @@ Begin
   InitTypedFile(F);
   FileRec(f).Name:=Name;
 End;
-{$ELSE}
-Procedure Assign(out f:TypedFile;const Name:string);
-{
-  Assign Name to file f so it can be used with the file routines
-}
-Begin
-   FillChar(f,SizeOF(FileRec),0);
-   FileRec(f).Handle:=UnusedHandle;
-   FileRec(f).mode:=fmClosed;
-  Move(Name[1],FileRec(f).Name,Length(Name));
-end;
- 
-Procedure Assign(out f:TypedFile;p:pchar);
-begin
-  Assign(f,StrPas(p));
-end;
-
-Procedure Assign(out f:TypedFile;c : char);
-begin
-  Assign(f,string(c));
-end;
-
-{$ENDIF}
-
 
 Procedure fpc_reset_typed(var f : TypedFile;Size : Longint);[Public,IOCheck, Alias:'FPC_RESET_TYPED']; compilerproc;
 Begin

+ 33 - 0
rtl/inc/uuchar.pp

@@ -21,7 +21,40 @@ interface
     char = widechar;
     pchar = pwidechar;
 
+
+Function ParamStr(Param : Integer) : UnicodeString;
+
 implementation
 
+{$if defined(FPC_HAS_FEATURE_COMMANDARGS) }
+Function ParamStr(Param : Integer) : unicodestring;
+
+Var Len : longint;
+    s   : ansistring;
+begin
+{
+  Paramstr(0) should return the name of the binary.
+  Since this functionality is included in the system unit,
+  we fetch it from there.
+  Normally, pathnames are less than 255 chars anyway,
+  so this will work correct in 99% of all cases.
+  In time, the system unit should get a GetExeName call.
+}
+  if (Param=0) then
+    Paramstr:=System.Paramstr(0)
+  else if (Param>0) and (Param<argc) then
+    begin
+    Len:=0;
+    While Argv[Param][Len]<>#0 do
+      Inc(len);
+    SetLength(s,Len);
+    If Len>0 then
+      Move(Argv[Param][0],s[1],Len);
+     paramstr:=s;
+    end
+  else
+    paramstr:='';
+end;
+{$endif FPC_HAS_FEATURE_COMMANDARGS}
 
 end.

+ 5 - 119
rtl/objpas/objpas.pp

@@ -59,54 +59,29 @@ Var
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
     { Untyped file support }
-
-     {$ifdef FPC_UNICODE_RTL}
      Procedure AssignFile(out f:File;const Name:UnicodeString);
      Procedure AssignFile(out f:File;const Name:RawByteString);
-     {$else}
-     Procedure AssignFile(out f:File;const Name:string);
-     Procedure AssignFile(out f:File;p:pchar);
-     Procedure AssignFile(out f:File;c:char);
-     {$endif}
      Procedure CloseFile(var f:File);
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
      { Text file support }
-     {$ifdef FPC_UNICODE_RTL}
      Procedure AssignFile(out f:Text;const Name:UnicodeString);
      Procedure AssignFile(out f:Text;const Name:RawByteString);
-     {$else}
-     Procedure AssignFile(out t:Text;const s:string);
-     Procedure AssignFile(out t:Text;p:pchar);
-     Procedure AssignFile(out t:Text;c:char);
-     {$endif}
      Procedure CloseFile(Var t:Text);
 {$endif FPC_HAS_FEATURE_TEXTIO}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
      { Typed file supoort }
-     {$ifdef FPC_UNICODE_RTL}
      Procedure AssignFile(out f:TypedFile;const Name:UnicodeString);
      Procedure AssignFile(out f:TypedFile;const Name:RawByteString);
-     {$else}
-     Procedure AssignFile(out f:TypedFile;const Name:string);
-     Procedure AssignFile(out f:TypedFile;p:pchar);
-     Procedure AssignFile(out f:TypedFile;c:char);
-     {$endif}
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 {$if defined(FPC_HAS_FEATURE_COMMANDARGS) }
      { ParamStr should return also an ansistring }
-     Function ParamStr(Param : Integer) : UnicodeString;
+     Function ParamStr(Param : Integer) : AnsiString;
 {$endif FPC_HAS_FEATURE_COMMANDARGS}
 
-{$if defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS) and not defined(FPC_UNICODE_RTL)}
-     Procedure MkDir(s:ansistring);overload;
-     Procedure RmDir(s:ansistring);overload;
-     Procedure ChDir(s:ansistring);overload;
-{$endif defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
-
 {****************************************************************************
                              Resource strings.
 ****************************************************************************}
@@ -144,15 +119,8 @@ Var
 ****************************************************************************}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-{$ifndef FPC_UNICODE_RTL}
-Procedure MkDirpchar(s: pchar;len:sizeuint);[IOCheck]; external name 'FPC_SYS_MKDIR';
-Procedure ChDirpchar(s: pchar;len:sizeuint);[IOCheck]; external name 'FPC_SYS_CHDIR';
-Procedure RmDirpchar(s: pchar;len:sizeuint);[IOCheck]; external name 'FPC_SYS_RMDIR';
-{$endif}
 
-{ Untyped file support }
-{$ifdef FPC_UNICODE_RTL}
-Procedure AssignFile(out f:File;const Name:RawBytestring);
+  Procedure AssignFile(out f:File;const Name:RawBytestring);
 begin
   System.Assign (F,Name);
 end;
@@ -161,23 +129,7 @@ Procedure AssignFile(out f:File;const Name:UnicodeString);
 begin
   System.Assign (F,Name);
 end;
-{$else}
-Procedure AssignFile(out f:File;const Name:string);
-begin
-  System.Assign (F,Name);
-end;
 
-Procedure AssignFile(out f:File;p:pchar);
-begin
-  System.Assign (F,P);
-end;
-
-Procedure AssignFile(out f:File;c:char);
-
-begin
-  System.Assign (F,C);
-end;
-{$endif}
 Procedure CloseFile(Var f:File); [IOCheck];
 
 begin
@@ -189,7 +141,6 @@ end;
 {$ifdef FPC_HAS_FEATURE_TEXTIO}
 { Text file support }
 
-{$ifdef FPC_UNICODE_RTL}
 Procedure AssignFile(out f:Text;const Name:RawBytestring);
 begin
   System.Assign (F,Name);
@@ -199,26 +150,6 @@ Procedure AssignFile(out f:Text;const Name:UnicodeString);
 begin
   System.Assign (F,Name);
 end;
-{$else}
-
-Procedure AssignFile(out t:Text;const s:string);
-
-begin
-  System.Assign (T,S);
-end;
-
-Procedure AssignFile(out t:Text;p:pchar);
-
-begin
-  System.Assign (T,P);
-end;
-
-Procedure AssignFile(out t:Text;c:char);
-
-begin
-  System.Assign (T,C);
-end;
-{$endif}
 
 Procedure CloseFile(Var t:Text); [IOCheck];
 
@@ -231,7 +162,6 @@ end;
 {$ifdef FPC_HAS_FEATURE_FILEIO}
 { Typed file support }
 
-{$ifdef FPC_UNICODE_RTL}
 Procedure AssignFile(out f:TypedFile;const Name:RawBytestring);
 begin
   System.Assign (F,Name);
@@ -241,32 +171,13 @@ Procedure AssignFile(out f:TypedFile;const Name:UnicodeString);
 begin
   System.Assign (F,Name);
 end;
-{$else}
-Procedure AssignFile(out f:TypedFile;const Name:string);
-
-begin
-  system.Assign(F,Name);
-end;
-
-Procedure AssignFile(out f:TypedFile;p:pchar);
-
-begin
-  system.Assign (F,p);
-end;
 
-Procedure AssignFile(out f:TypedFile;c:char);
-
-begin
-  system.Assign (F,C);
-end;
-{$endif}
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 {$if defined(FPC_HAS_FEATURE_COMMANDARGS) }
-Function ParamStr(Param : Integer) : unicodestring;
+Function ParamStr(Param : Integer) : ansistring;
 
 Var Len : longint;
-    s   : ansistring;
 begin
 {
   Paramstr(0) should return the name of the binary.
@@ -283,40 +194,15 @@ begin
     Len:=0;
     While Argv[Param][Len]<>#0 do
       Inc(len);
-    SetLength(s,Len);
+    SetLength(result,Len);
     If Len>0 then
-      Move(Argv[Param][0],s[1],Len);
-     result:=s;
+      Move(Argv[Param][0],result[1],Len);
     end
   else
     Result:='';
 end;
 {$endif FPC_HAS_FEATURE_COMMANDARGS}
 
-
-{$if defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS) and not defined(FPC_UNICODE_RTL)}
-{ xxDirPChar procedures can adjust directory separators in supplied string (at least
-  Windows implementation does so). Therefore full copy of argument is needed,
-  just passing by value isn't enough because it won't copy a string literal. }
-Procedure MkDir(s:ansistring);[IOCheck];
-begin
-  UniqueString(s);
-  mkdirpchar(pchar(s),length(s));
-end;
-
-Procedure RmDir(s:ansistring);[IOCheck];
-begin
-  UniqueString(s);
-  RmDirpchar(pchar(s),length(s));
-end;
-
-Procedure ChDir(s:ansistring);[IOCheck];
-begin
-  UniqueString(s);
-  ChDirpchar(pchar(s),length(s));
-end;
-{$endif defined(FPC_HAS_FEATURE_FILEIO) and defined(FPC_HAS_FEATURE_ANSISTRINGS)}
-
 {$ifdef FPC_HAS_FEATURE_RESOURCES}
 { ---------------------------------------------------------------------
     ResourceString support

+ 0 - 1
rtl/objpas/sysutils/filutil.inc

@@ -96,7 +96,6 @@ end;
 {$endif}
 
 function FileAge(const FileName: RawByteString; out FileDateTime: TDateTime; FollowLink: Boolean = True): Boolean;
-   
 Var
   Info : TSearchRec;
   A : Integer;

+ 4 - 49
rtl/unix/sysdir.inc

@@ -25,7 +25,6 @@ const
                S_IWOTH OR S_IROTH OR
                S_IXUSR OR S_IXGRP OR S_IXOTH;
 
-{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_MkDir(s: rawbytestring);[IOCheck];
 
 Begin
@@ -37,6 +36,7 @@ Begin
    InOutRes:=0;
 End;
 
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_MkDir(s: unicodestring);[IOCheck];
 
 Var
@@ -46,25 +46,12 @@ begin
   R:=ToSingleByteFileSystemEncodedFileName(S);
   Do_MkDir(R);  
 end;
-
-{$ELSE}
-
-Procedure do_MkDir(p: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_MKDIR'];
-Begin
-  If (P=nil) or (p[0]=#0) or (InOutRes <> 0) then
-    exit;
-  If Fpmkdir(p, MODE_MKDIR)<0 Then
-   Errno2Inoutres
-  Else
-   InOutRes:=0;
-End;
 {$ENDIF}
 
 // len is not passed to the *nix functions because the unix API doesn't 
 // use length safeguards for these functions. (probably because there
 // already is a length limit due to PATH_MAX)
 
-{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_RmDir(s: rawbytestring);[IOCheck];
 
 begin
@@ -78,8 +65,8 @@ begin
    InOutRes:=0;
 End;
 
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_RmDir(s: unicodestring);[IOCheck];
-
 Var
   R : RawByteString;
 
@@ -87,23 +74,8 @@ begin
   R:=ToSingleByteFileSystemEncodedFileName(S);
   Do_RMDir(R);  
 end;
-
-{$ELSE}
-Procedure do_RMDir(p: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_RMDIR'];
-
-Begin
-  if (len=1) and (p^ = '.') then
-    InOutRes := 16;
-  If not assigned(p) or (len=0) or (InOutRes <> 0) then
-    exit;
-  If Fprmdir(p)<0 Then
-   Errno2Inoutres
-  Else
-   InOutRes:=0;
-End;
 {$ENDIF}
 
-{$IFDEF FPC_UNICODE_RTL}
 Procedure do_ChDir(s: rawbytestring);[IOCheck];
 
 Begin
@@ -118,8 +90,8 @@ Begin
    InOutRes:=3;
 End;
 
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_ChDir(s: unicodestring);[IOCheck];
-
 Var
   R : RawByteString;
 
@@ -127,19 +99,6 @@ begin
   R:=ToSingleByteFileSystemEncodedFileName(S);
   Do_ChDir(R);  
 end;
-
-{$ELSE}
-
-Procedure do_ChDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_CHDIR'];
-Begin
-  If not assigned(s) or (len=0) or (InOutRes <> 0) then
-    exit;
-  If Fpchdir(s)<0 Then
-    Errno2Inoutres
-   Else
-    InOutRes:=0;
-end;
-
 {$ENDIF}
 
 // !! for now we use getcwd, unless we are fpc_use_libc.
@@ -150,11 +109,7 @@ end;
 // !! dos legacy api's better visibile due to cut-off path, instead of "empty"
 
 
-{$IFDEF FPC_UNICODE_RTL}
 procedure do_getdir(drivenr : byte;var dir : rawbytestring);
-{$ELSE}
-procedure getdir(drivenr : byte;var dir : shortstring);
-{$ENDIF}
 var
   buf          : array[0..2047] of char;
   cwdinfo      : stat;
@@ -238,4 +193,4 @@ begin
   do_getdir(drivenr,S);
   dir:=S;
 end;
-{$ENDIF}
+{$ENDIF}

+ 18 - 59
rtl/unix/sysfile.inc

@@ -22,19 +22,16 @@ Begin
   until (res<>-1) or (geterrno<>ESysEINTR);
 End;
 
-{$IFDEF FPC_UNICODE_RTL}
-Procedure Do_Erase(S : UnicodeString);
+Procedure Do_Erase(p : RawByteString);
 
 var
   fileinfo : stat;
-  R : RawByteString;
 
 Begin
-  R:=ToSingleByteFileSystemEncodedFileName(S);
   { verify if the filename is actually a directory }
   { if so return error and do nothing, as defined  }
   { by POSIX                                       }
-  if Fpstat(PChar(R),fileinfo)<0 then
+  if Fpstat(pchar(P),fileinfo)<0 then
    begin
      Errno2Inoutres;
      exit;
@@ -44,37 +41,21 @@ Begin
      InOutRes := 2;
      exit;
    end;
-  if Fpunlink(pchar(R))<0 then
+  if Fpunlink(pchar(p))<0 then
    Errno2Inoutres
   Else
    InOutRes:=0;
 End;
-{$ELSE}
-Procedure Do_Erase(p : pchar);
 
+{$IFDEF FPC_UNICODE_RTL}
+Procedure Do_Erase(S : UnicodeString);
 var
-  fileinfo : stat;
-
+  R : RawByteString;
 Begin
-  { verify if the filename is actually a directory }
-  { if so return error and do nothing, as defined  }
-  { by POSIX                                       }
-  if Fpstat(P,fileinfo)<0 then
-   begin
-     Errno2Inoutres;
-     exit;
-   end;
-  if FpS_ISDIR(fileinfo.st_mode) then
-   begin
-     InOutRes := 2;
-     exit;
-   end;
-  if Fpunlink(p)<0 then
-   Errno2Inoutres
-  Else
-   InOutRes:=0;
-End;
-{$ENDIF}
+  R:=ToSingleByteFileSystemEncodedFileName(S);
+  Do_Erase(R);
+end;
+{$endif}
 
 { truncate at a given position }
 procedure do_truncate (handle:thandle;fpos:longint);
@@ -87,12 +68,9 @@ begin
    InOutRes:=0;
 end;
 
-{$IFDEF FPC_UNICODE_RTL}
-Procedure Do_Rename(Src : UnicodeString; Dest : RawByteString);
-
+Procedure Do_Rename(Src : RawByteString; Dest : RawByteString);
 Var
  S : RawbyteString;
-
 Begin
   S:=ToSingleByteFileSystemEncodedFileName(Src);
   If Fprename(Pchar(S),Pchar(Dest))<0 Then
@@ -101,26 +79,16 @@ Begin
     InOutRes:=0;
 End;
 
-
+{$IFDEF FPC_UNICODE_RTL}
 Procedure Do_Rename(Src,Dest : UnicodeString);
-
 Var
- S : RawbyteString;
-
+ sdest,ssrc : RawbyteString;
 Begin
-  S:=ToSingleByteFileSystemEncodedFileName(Dest);
-  Do_Rename(Src,S);
+  SDest:=ToSingleByteFileSystemEncodedFileName(Dest);
+  SSrc:=ToSingleByteFileSystemEncodedFileName(Src);
+  Do_Rename(SSrc,SDest);
 end;
-{$ELSE}
-Procedure Do_Rename(p1,p2:pchar);
-
-Begin
-  If Fprename(P1,P2)<0 Then
-    Errno2Inoutres
-  Else
-    InOutRes:=0;
-End;
-{$ENDIF}
+{$endif}
 
 Function Do_Write(Handle:thandle;Addr:Pointer;Len:Longint):longint;
 
@@ -200,11 +168,7 @@ Begin
    InOutRes:=0;
 End;
 
-{$IFNDEF FPC_UNICODE_RTL}
-Procedure Do_Open(var f; p:pchar; flags:longint);
-{$ELSE}
 Procedure Do_Open(var f; const s : RawByteString;flags:longint);
-{$ENDIF}
 
 {
   FileRec and textrec have both Handle and mode as the first items so
@@ -220,13 +184,9 @@ const
               S_IWOTH OR S_IROTH;
 var
   oflags : cint;
-{$IFDEF FPC_UNICODE_RTL}
   p : pchar;
-{$ENDIF}
 Begin
-{$IFDEF FPC_UNICODE_RTL}
   p:=pchar(S);
-{$ENDIF}
   {}
 { close first if opened }
   if ((flags and $10000)=0) then
@@ -299,7 +259,6 @@ Begin
 End;
 
 {$IFDEF FPC_UNICODE_RTL}
-
 Procedure Do_Open(var f; const s : UnicodeString;flags:longint);
 
 Var
@@ -309,4 +268,4 @@ begin
   R:=ToSingleByteFileSystemEncodedFileName(S);
   Do_open(F,R,Flags);
 end;
-{$ENDIF}
+{$ENDIF}

+ 0 - 1
rtl/win/dos.pp

@@ -833,7 +833,6 @@ function GetVersionEx(var VersionInformation:OSVERSIONINFO) : longbool;
 function GetProcAddress(hModule : THandle;lpProcName : pchar) : pointer;
   stdcall; external 'kernel32' name 'GetProcAddress';
 
-
 begin
    GetDiskFreeSpaceEx:=nil;
    kernel32dll:=GetModuleHandle('kernel32');

+ 44 - 43
rtl/win/sysdir.inc

@@ -21,6 +21,11 @@ type
  TDirFnType=function(name:pointer):longbool;stdcall;
 
 {$ifdef FPC_UNICODE_RTL}
+function CreateDirectoryTrunc(name:pointer):longbool;stdcall;
+begin
+  CreateDirectoryTrunc:=CreateDirectory(name,nil);
+end;
+
 procedure dirfn(afunc : TDirFnType;s:unicodestring);
 begin
   DoDirSeparators(s);
@@ -30,12 +35,6 @@ begin
       Errno2InoutRes;
     end;
 end;
-
-function CreateDirectoryTrunc(name:pointer):longbool;stdcall;
-begin
-  CreateDirectoryTrunc:=CreateDirectory(name,nil);
-end;
-
 Procedure do_MkDir(const s: UnicodeString);[IOCheck];
 begin
   If (length(s)=0) or (InOutRes <> 0) then
@@ -43,11 +42,6 @@ begin
   dirfn(TDirFnType(@CreateDirectoryTrunc),s);
 end;
 
-Procedure do_MkDir(const s: RawByteString);[IOCheck];
-begin
-  do_mkdir(UnicodeString(s));
-end;
-
 Procedure do_RmDir(const s: UnicodeString);[IOCheck];
 begin
   if (s ='.') then
@@ -65,11 +59,6 @@ begin
 {$endif WINCE}
 end;
 
-Procedure do_RmDir(const s: RawByteString);[IOCheck];
-begin
-  do_RmDir(UnicodeString(s));
-end;
-
 Procedure do_ChDir(const s: UnicodeString);[IOCheck];
 begin
 {$ifndef WINCE}
@@ -83,17 +72,12 @@ begin
 {$endif WINCE}
 end;
 
-Procedure do_ChDir(const s: RawByteString);[IOCheck];
-begin
-  do_ChDir(UnicodeString(s));
-end;
-
 procedure do_GetDir (DriveNr: byte; var Dir: Unicodestring);
 {$ifndef WINCE}
 var
   Drive:array[0..3]of char;
   defaultdrive:boolean;
-  DirBuf,SaveBuf:array[0..259] of WideChar;
+  savebuf: UnicodeString;
   len : integer;
 {$endif WINCE}
 begin
@@ -105,7 +89,10 @@ begin
     Drive[1]:=':';
     Drive[2]:=#0;
     Drive[3]:=#0;
-    GetCurrentDirectory(high(SaveBuf)+1,SaveBuf); // in TChar
+    len:=GetCurrentDirectory(0,nil); // in TChar
+    setlength(savebuf,len-1); // -1 because len is #0 inclusive
+
+    GetCurrentDirectory(high(SaveBuf)+1,punicodechar(SaveBuf)); // in TChar
     if not SetCurrentDirectory(@Drive) then
      begin
       errno := word (GetLastError);
@@ -120,27 +107,42 @@ begin
   setlength(dir,len-1); // -1 because len is #0 inclusive
   GetCurrentDirectory(len,punicodechar(dir));
   if not defaultdrive then
-   SetCurrentDirectory(@SaveBuf);
+    SetCurrentDirectory(@SaveBuf);
   if not FileNameCasePreserving then
-   dir:=upcase(dir);
+    dir:=upcase(dir);
     {todo: massive loss of encoding and number of chars}
 {$else WINCE}
   Dir:='\';
 {$endif WINCE}
 end;
 
-procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
+Procedure do_MkDir(const s: RawByteString);[IOCheck];
+begin
+  do_mkdir(UnicodeString(s));
+end;
+
+Procedure do_RmDir(const s: RawByteString);[IOCheck];
+begin
+  do_RmDir(UnicodeString(s));
+end;
+
+Procedure do_ChDir(const s: RawByteString);[IOCheck];
+begin
+  do_ChDir(UnicodeString(s));
+end;
 
+procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
 var ldir : Unicodestring;
 begin
   do_GetDir(DriveNr,ldir);
   dir:=ToSingleByteFileSystemEncodedFileName(ldir);
 end;
 {$else}
-procedure dirfn(afunc : TDirFnType;s:pchar;len:integer);
+
+procedure dirfn(afunc : TDirFnType;dir:RawByteString);
 begin
-  DoDirSeparators(s);
-  if not aFunc(s) then
+  DoDirSeparators(dir);
+  if not aFunc(pchar(dir)) then
     begin
       errno:=GetLastError;
       Errno2InoutRes;
@@ -152,38 +154,36 @@ begin
   CreateDirectoryTrunc:=CreateDirectory(name,nil);
 end;
 
-Procedure do_MkDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_MKDIR'];
+Procedure do_MkDir(const s: RawByteString);[IOCheck];
 begin
-  If not assigned(s) or (len=0) or (InOutRes <> 0) then
+  If (s='') or  (InOutRes <> 0) then
    exit;
-  dirfn(TDirFnType(@CreateDirectoryTrunc),s,len);
+  dirfn(TDirFnType(@CreateDirectoryTrunc),s);
 end;
 
-Procedure do_RmDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_RMDIR'];
-
+Procedure do_RmDir(const s: RawByteString);[IOCheck];
 begin
-  if (len=1) and (s^ ='.') then
+  if (s ='.') then
     InOutRes := 16;
-  If not assigned(s) or (len=0) or (InOutRes <> 0) then
+  If (s='') or (InOutRes <> 0) then
    exit;
 {$ifdef WINCE}
   if (len=2) and (s[0]='.') and (s[1]='.') then
     InOutRes := 5;
 {$endif WINCE}
-  dirfn(TDirFnType(@RemoveDirectory),s,len);
+  dirfn(TDirFnType(@RemoveDirectory),s);
 {$ifdef WINCE}
   if (Inoutres=3) and (Pos(DirectorySeparator, s)<2) then
     Inoutres:=2;
 {$endif WINCE}
 end;
 
-Procedure do_ChDir(s: pchar;len:sizeuint);[IOCheck, public, alias : 'FPC_SYS_CHDIR'];
-
+Procedure do_ChDir(const s: RawByteString);[IOCheck];
 begin
 {$ifndef WINCE}
-  If not assigned(s) or (len=0) or (InOutRes <> 0) then
+  If (s='.') or (InOutRes <> 0) then
    exit;
-  dirfn(TDirFnType(@SetCurrentDirectory),s,len);
+  dirfn(TDirFnType(@SetCurrentDirectory),s);
   if Inoutres=2 then
    Inoutres:=3;
 {$else WINCE}
@@ -191,7 +191,8 @@ begin
 {$endif WINCE}
 end;
 
-procedure GetDir (DriveNr: byte; var Dir: ShortString);
+procedure do_GetDir (DriveNr: byte; var Dir: RawByteString);
+// this old implementation is wired -A and thus is >260 char.
 {$ifndef WINCE}
 var
   Drive:array[0..3]of char;
@@ -220,7 +221,7 @@ begin
   GetCurrentDirectory(SizeOf(DirBuf),DirBuf);
   if not defaultdrive then
    SetCurrentDirectory(@SaveBuf);
-  dir:=strpas(DirBuf);
+  dir:=DirBuf;
   if not FileNameCasePreserving then
    dir:=upcase(dir);
 {$else WINCE}

+ 7 - 11
rtl/win/sysfile.inc

@@ -72,15 +72,15 @@ begin
   do_rename(p1,unicodestring(p2));
 end;
 {$else}
-procedure do_erase(p : pchar);
+procedure do_erase(p : rawbytestring);
 begin
    DoDirSeparators(p);
-   if DeleteFile(p)=0 then
+   if DeleteFile(pchar(p))=0 then
     Begin
       errno:=GetLastError;
       if errno=5 then
        begin
-         if ((GetFileAttributes(p) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
+         if ((GetFileAttributes(pchar(p)) and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY) then
           errno:=2;
        end;
       Errno2InoutRes;
@@ -88,11 +88,11 @@ begin
 end;
 
 
-procedure do_rename(p1,p2 : pchar);
+procedure do_rename(p1,p2 : rawbytestring);
 begin
   DoDirSeparators(p1);
   DoDirSeparators(p2);
-  if MoveFile(p1,p2)=0 then
+  if MoveFile(pchar(p1),pchar(p2))=0 then
    Begin
       errno:=GetLastError;
       Errno2InoutRes;
@@ -234,7 +234,7 @@ end;
 {$ifdef FPC_UNICODE_RTL}
 procedure do_open(var f;const op:unicodestring;flags:longint);
 {$else}
-procedure do_open(var f;p:pchar;flags:longint);
+procedure do_open(var f;p:RawByteString;flags:longint);
 {$endif}
 {
   filerec and textrec have both handle and mode as the first items so
@@ -316,11 +316,7 @@ begin
   else
     cd:=OPEN_EXISTING;
   { empty name is special }
-{$ifdef FPC_UNICODE_RTL}
   if p='' then
-{$else}
-  if p[0]=#0 then
-{$endif}
    begin
      case FileRec(f).mode of
        fminput :
@@ -342,7 +338,7 @@ begin
   {$ifdef FPC_UNICODE_RTL}
   filerec(f).handle:=CreateFile(punicodechar(p),oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
   {$else}
-  filerec(f).handle:=CreateFile(p,oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
+  filerec(f).handle:=CreateFile(pchar(p),oflags,shflags,@security,cd,FILE_ATTRIBUTE_NORMAL,0);
   {$endif}
   { append mode }
   if ((flags and $100)<>0) and

+ 6 - 6
rtl/win/sysutils.pp

@@ -488,7 +488,7 @@ begin
   WinToDosTime(F.FindData.ftLastWriteTime,F.Time);
   f.size:=F.FindData.NFileSizeLow+(qword(maxdword)+1)*F.FindData.NFileSizeHigh;
   f.attr:=F.FindData.dwFileAttributes;
-  f.Name:=StrPas(@F.FindData.cFileName[0]);
+  f.Name:=F.FindData.cFileName[0];
   Result:=0;
 end;
 
@@ -539,7 +539,7 @@ begin
   WinToDosTime(F.FindData.ftLastWriteTime,F.Time);
   f.size:=F.FindData.NFileSizeLow+(qword(maxdword)+1)*F.FindData.NFileSizeHigh;
   f.attr:=F.FindData.dwFileAttributes;
-  f.Name:=StrPas(@F.FindData.cFileName[0]);
+  f.Name:=F.FindData.cFileName;
   Result:=0;
 end;
 
@@ -1119,7 +1119,7 @@ begin
                  MsgBuffer,                 { This function allocs the memory }
                  MaxMsgSize,                           { Maximum message size }
                  nil);
-  SysErrorMessage := StrPas(MsgBuffer);
+  SysErrorMessage := MsgBuffer;
   FreeMem(MsgBuffer, MaxMsgSize);
 end;
 
@@ -1143,7 +1143,7 @@ begin
    hp:=p;
    while hp^<>#0 do
      begin
-        s:=strpas(hp);
+        s:=hp;
         i:=pos('=',s);
         if uppercase(copy(s,1,i-1))=upcase(envvar) then
           begin
@@ -1168,7 +1168,7 @@ begin
    hp:=p;
    while hp^<>#0 do
      begin
-        s:=strpas(hp);
+        s:=hp;
         i:=pos('=',s);
         if uppercase(copy(s,1,i-1))=uppercase(envvar) then
           begin
@@ -1214,7 +1214,7 @@ begin
       hp:=hp+strlen(hp)+1;
       end;
     If (hp^<>#0) then
-      Result:=StrPas(HP);
+      Result:=HP;
     end;
   FreeEnvironmentStringsA(p);
 end;

+ 1 - 1
rtl/win/syswin.inc

@@ -240,7 +240,7 @@ const
 {$ifdef FPC_UNICODE_RTL}
       paramstr:=(argv[l])
 {$else}
-      paramstr:=strpas(argv[l])
+      paramstr:=argv[l]
 {$endif}
     else
       paramstr:='';

+ 1 - 1
rtl/win/windirs.pp

@@ -72,7 +72,7 @@ var
 Procedure InitDLL;
 
 Var
-  pathBuf: array[0..MAX_PATH-1] of {$ifdef FPC_UNICODE_RTL}WideChar{$else}char{$endif};
+  pathBuf: array[0..MAX_PATH-1] of {$ifdef FPC_UNICODE_RTL}WideChar{$else}Ansichar{$endif};
   pathLength: Integer;
 begin
   { Load shfolder.dll using a full path, in order to prevent spoofing (Mantis #18185)