[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issue with dir & long path/file name

From: Philip Nienhuis
Subject: Re: Issue with dir & long path/file name
Date: Fri, 9 Jan 2015 12:19:19 -0800 (PST)

am304 wrote
> I am currently writing a small program to parse a directory structure and
> retrieve some data from files in that structure. The files of interest are
> not always in the same consistent location, so I have to search for them,
> and to do so, I make extensive use of the dir function.
> I have come up against an issue, which I don't know how to solve. For some
> files, I get the following warning when calling the dir function:
> warning: dir: 'lstat
> (P:\9xxxProjects\blabla\blabla\blabla\blabla\blabla\blabla\blabla\long_filename)'
> failed: No such file or directory
> and the resulting elements in the structure output from dir are:
> ans = .
> ans = ..
> ans = [](0x0)
> ans = [](0x0)
> ans = [](0x0)
> ans = [](0x0)
> ans = [](0x0)
> which makes my code error out.
> Now, I have created a test directory in the base C:\ drive (C:\Test),
> copied the files across, and without changing anything else (i.e. leaving
> the file names unchanged), ran the same code. It ran just fine, no issues
> with dir.
> Is there a maximum path/file length that is supported by dir? How can I
> work around this problem? I cannot change the naming convention of either
> directory structures or the file names. The length of the path to the
> problem directory is 177, the length of the file names that give me
> problems is 84, so a combined length of 261. Other files in that same
> directory, of length 81 (so combined length of 258), work just fine. Is
> there a maximum length of 260 characters somewhere in the code?

The maximum path length on Windows is 256 chars (excl. drive letter & colon
& backslash & terminating NULL character [1].
There's a way around when using Unicode, but Octave doesn't support that

In practice any full path name >= 250 characters should be considered close
to the edge on Windows. 



View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]