bugGNU Octave - Bugs: bug #57776, "dir" fails on the root...


bug #57776: "dir" fails on the root directory of Windows UNC shares

Submitted by:  Markus Mützel <mmuetzel>
Submitted on:  Sun 09 Feb 2020 11:42:43 AM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sat 22 Feb 2020 01:14:26 PM UTC, comment #5: 

Works for me now.
Closing as fixed.

Markus Mützel <mmuetzel>
Project Member
Sun 09 Feb 2020 09:29:09 PM UTC, comment #4: 

I pushed this change that fixes the issues described in comment #0 for me:

Marking as Ready For Test.

Markus Mützel <mmuetzel>
Project Member
Sun 09 Feb 2020 03:14:23 PM UTC, comment #3: 

@Philip: I think you have been on to something. This code snippet from file_stat::update_internal (in file-stat.cc @ line 192) removes trailing slashes on Windows unless "full_file_name" is a root (like "C:\"):

#if defined (__WIN32__)
          // Remove trailing slash.
          if (full_file_name.length () > 1
              && sys::file_ops::is_dir_sep (full_file_name.back ())
              && ! (full_file_name.length () == 3 && full_file_name[1] == ':'))
            full_file_name.pop_back ();

Probably, this should also NOT remove the trailing slash if "full_file_name" is a UNC root (like "\\SERVER\share\").

Sure enough, I see the following:

>> [st, err, msg] = lstat ('\\SERVER\share\')
st = [](0x0)
err = -1
msg = No such file or directory
>> [st, err, msg] = lstat ('\\SERVER\share\\')
st =

  scalar structure containing the fields:

    dev = 3
    ino = 0
    mode = 16895
    modestr = drwxrwxrwx
    nlink = 1
    uid = 0
    gid = 0
    rdev = 3
    size = 0
    atime = 3.1553e+08
    mtime = 3.1553e+08
    ctime = 3.1553e+08
    blksize = NaN
    blocks = NaN

err = 0
msg =

Markus Mützel <mmuetzel>
Project Member
Sun 09 Feb 2020 01:07:02 PM UTC, comment #2: 

Same behavior with trailing backslashes.
Also note that the ".." entry is missing in the second case.

Markus Mützel <mmuetzel>
Project Member
Sun 09 Feb 2020 01:04:18 PM UTC, comment #1: 

Does it work if you add a trailing backslash?
Maybe related: the GUI file browser doesn't accept "C:" but does accept "C:\". So there is something special with root directories.

Philip Nienhuis <philipnienhuis>
Project Member
Sun 09 Feb 2020 11:42:43 AM UTC, original submission:  

Trying to list the directory content of a root folder of a UNC share on Windows results in an error:

>> dir ('\\SERVER\share')
warning: dir: nonexistent directory '\\SERVER\share'
warning: called from
    dir at line 193 column 5

It does work to list the content of a sub-directory in the share (albeit displaying a warning):

>> dir ('\\SERVER\share\test')
warning: dir: 'lstat (\\SERVER\share\test\..)' failed: No such file or directory
warning: called from
    dir at line 132 column 9

.                 a                 test.txt          test_unc.m
Octave (GUI).lnk  b                 test_octave.bat

Both commands should succeed without displaying a warning.

Markus Mützel <mmuetzel>
Project Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-02-22 mmuetzel StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
    2020-02-09 mmuetzel StatusNone => Ready For Test

    Back to the top

    Powered by Savane 3.5