On Sat, August 31, 2013 15:59, Bart wrote: > On 8/31/13, Michael Van Canneyt <mich...@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@localhost 012345679]$ pwd > /home/bart/X/01DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD/012345679 > > Here's the program source: > > [bart@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@localhost 012345679]$ ~/LazarusProjecten/bugs/findfirst/efn . > /home/bart/X/01DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD > [Length = 255] > [bart@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;
Oops, sorry, you're right - I was focusing the ParamStr part too much in my previous post without realizing that the dot in your example is not expanded by the shell, of course. :-( Passing the directory name directly on the command line would still give a similar issue. Now, as you have already found out yourself too, it is not an issue with ExpandFileName only, but also with the overloaded version of GetDir returning ansistring but still limited to 255 characters. I could provide a workaround for ExpandFileName (using SysUtils.GetCurrentDir and basically replicating the implementation of System.GetDir under Windows except for using ansistrings), but fixing the ansistring overloaded version of System.GetDir sound as a more appropriate option to me. Tomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal