[fpc-pascal] ExpandFileName failure on long filenames on Linux
    Bart 
    bartjunk64 at gmail.com
       
    Sat Aug 31 15:59:29 CEST 2013
    
    
  
On 8/31/13, Michael Van Canneyt <michael at freepascal.org> wrote:
> Did you enable ansistrings and object pascal mode ?
> Because as it is displayed above, the program will use shortstrings, and
> they are limited to 255 chars.
Yes (I typed the example from the top if my head):
(ObjFpc mode should not matter though as long as {$H+} is specified?)
Here's my very long directory:
[bart at localhost 012345679]$ pwd
/home/bart/X/01DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD/012345679
Here's the program source:
[bart at localhost 012345679]$ cat ~/LazarusProjecten/bugs/findfirst/efn.lpr
program efn;
{$mode objfpc}
{$H+}
uses sysutils;
var
  S: String;
  Len: Integer;
begin
  S := SysUtils.ExpandFileName(ParamStr(1));
  Len := Length(S);
  writeln(Format('%s [Length = %d]',[S,Len]));
end.
And this is what it outputs.
[bart at localhost 012345679]$ ~/LazarusProjecten/bugs/findfirst/efn .
/home/bart/X/01DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
[Length = 255]
[bart at localhost 012345679]$
At some point a call is made to
Procedure getdir(drivenr:byte;var dir:ansistring);
(rtl/inc/sysem.inc)
This then calls the ShortString version of GetDir() and puts the
resulting ShortString back into the AnsiString.
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;
Bart
    
    
More information about the fpc-pascal
mailing list