Skip to main content.
home | support | download

Back to List Archive

Re: Error dealing with long pathnames in Win32

From: SRE <eckert(at)not-real.climber.org>
Date: Tue Feb 19 2002 - 19:21:27 GMT
At 09:54 AM 2/19/02, David L Norris wrote:
>I think perhaps OFS_MAXPATHNAME isn't the correct thing to be using. 
>I'm looking into it...

Just for grins, I ran the following trivial Perl fragment on WinNT...
it seems you can't quite get to 256 chars with just the directory
path, but indeed the limit is on the total path, not just on the
file name length.

$path = "/temp";
for($x=0; $x<256; $x++)
  {
  $path .= "/dir$x";
  $len = length($path);
  mkdir($path,0x777) or die "Can't make $len char directory $path";

  $file = "file$x";
  $len = length("$path/$file");
  open(TMP,">$path/$file") or die "Can't make $len char file $path/$file";
  close TMP;

  $file = "this is a really long file $x";
  $len = length("$path/$file");
  open(TMP,">$path/$file") or die "Can't make $len char file $path/$file";
  close TMP;
  }


"AS IS", that loop generates the following output:

Can't make 259 char file /temp/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/dir11/dir12/dir13/dir14/dir15/dir16/dir17/dir18/dir19/dir20/dir21/dir22/dir23/dir24/dir25/dir26/dir27/dir28/dir29/dir30/dir31/dir32/dir33/dir34/dir35/dir36/dir37/dir38/this is a really long file 38 at sre.pl line 15.



REMOVING THE SECOND FILE OPEN, it fails on dir length first, and NOT at 256:

Can't make 247 char directory /temp/dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/dir11/dir12/dir13/dir14/dir15/dir16/dir17/dir18/dir19/dir20/dir21/dir22/dir23/dir24/dir25/dir26/dir27/dir28/dir29/dir30/dir31/dir32/dir33/dir34/dir35/dir36/dir37/dir38/dir39/dir40/dir41


SRE

mailto:eckert(at)not-real.climber.org | http://www.climber.org/eckert/
Info on peak climbing email lists mailto:info@climber.org

If you ask a question you don't want an answer to,
expect an answer that you don't want to hear!
Received on Tue Feb 19 19:21:48 2002