title: Filename too long in Octave
body: <p>I am currently writing a small program in Octave (3.8.0, on Windows) 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 <code>dir</code> function.</p>
  
  <p>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:</p>
  
  <pre><code>warning: dir: 'lstat (P:\9xxxProjects\blabla\blabla\blabla\blabla\blabla\blabla\blabla\long_filename)' failed: No such file or directory
  </code></pre>
  
  <p>and the resulting elements in the structure output from <code>dir</code> are:</p>
  
  <pre><code>&gt;&gt; test.name
  ans = .
  ans = ..
  ans = [](0x0)
  ans = [](0x0)
  ans = [](0x0)
  ans = [](0x0)
  ans = [](0x0)
  </code></pre>
  
  <p>which makes my code error out.</p>
  
  <p>Now, I have created a test directory in the base <code>C:\</code> drive (<code>C:\Test</code>), 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 <code>dir</code>. </p>
  
  <p>Is there a maximum path/file length that is supported by <code>dir</code>? How can I work around this problem? I cannot change the naming convention of either the directory structure 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?</p>
  
  <p>I have narrowed down the issue to the the call to <code>lstat</code> and <code>stat</code> in <code>dir</code>:</p>
  
  <pre><code>[st, err, msg] = lstat (fn);
  if (err &lt; 0)
     warning ("dir: 'lstat (%s)' failed: %s", fn, msg);          
  else
     ## If we are looking at a link that points to something,
     ## return info about the target of the link, otherwise, return
     ## info about the link itself.
     if (S_ISLNK (st.mode))
       [xst, err, msg] = stat (fn);
       if (! err)
         st = xst;
       endif
     endif
  </code></pre>
  
  <p>Here's what I get when I call <code>lstat</code> and <code>stat</code> with my problem file/directory:</p>
  
  <pre><code>&gt;&gt; [st, err, msg] = lstat(fullfile(problem_dir,file_name_test))
  st = [](0x0)
  err = -1
  msg = No such file or directory
  
  &gt;&gt; [xst, err, msg] = stat(fullfile(problem_dir,file_name_test))
  xst = [](0x0)
  err = -1
  msg = Filename too long
  </code></pre>
  
  <p>Unfortunately, both <code>stat</code> and <code>lstat</code> are built-in/compiled functions so I can't edit them. Can anybody suggest a workaround?</p>