bugGNU Octave - Bugs: bug #67050, copyfile fails with very long file...

 
 

bug #67050: copyfile fails with very long file names on Windows

Submitter:  Richard Suchland <suchland>
Submitted:  Thu 24 Apr 2025 02:35:16 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Need Info Assigned to:  None
Originator Name:  suchland Open/Closed:  * Open
Release:  * 10.1.0 Release: 
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 30 May 2025 05:25:16 PM UTC, comment #15: 

Seems that this is specific to user's PC, rather than an issue with Octave.  Can this report be closed?

Rik <rik5>
Group administrator
Fri 25 Apr 2025 08:23:39 PM UTC, comment #14: 

Actual device path to an external drive may be quite long since Windows would use GUID and such. See e.g.:

https://community.silabs.com/s/article/windows-usb-device-path?language=en_US


Dmitri A. Sergatskov <dasergatskov>
Fri 25 Apr 2025 08:00:34 PM UTC, comment #13: 

my computer is not in a company system.

C: is an SDD attached to the motherboard.
L: is an SDD cabled to the motherboard.

Richard Suchland <suchland>
Fri 25 Apr 2025 07:54:22 PM UTC, comment #12: 


> L: is a local drive letter
> L: is a 1TB SDD


Even then, in company environments, it can be mapped somewhere in a file system tree.
But from your answer I surmise it's a real separate physical partition on an SSD that is physically separate from the HD/SSD your Windows system drive C: lives on.

OK that at least eliminates a few possibilities.
But it doesn't help finding the cause of, or even fixing your issue.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 25 Apr 2025 04:15:48 PM UTC, comment #11: 

L: is a local drive letter
L: is a 1TB SDD
L:\>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]
SUBST drive1: /D

  drive1:        Specifies a virtual drive to which you want to assign a path.
  [drive2:]path  Specifies a physical drive and path you want to assign to
                 a virtual drive.
  /D             Deletes a substituted (virtual) drive.

Type SUBST with no parameters to display a list of current virtual drives.

L:\>SUBST

L:\>


Richard Suchland <suchland>
Fri 25 Apr 2025 01:43:19 PM UTC, comment #10: 

Is L: a real separate partition?

Even if L: is a local drive letter, it can just be a sort of symlink into an NTFS file system (IIRC a "join" in Windows parlance), so when expanded (behind your back) to the actual root of an NTFS file system a full path name can still hit the 260 char length limit.
(Under DOS these things were created with the SUBST command, AFAIR.  Hmm SUBST still works in Win10, just try 'subst /?' in a cmd window)

Philip Nienhuis <philipnienhuis>
Group Member
Thu 24 Apr 2025 09:05:38 PM UTC, comment #9: 

L: is a local drive.
I can see the longer names is Windows but not in DOS (i.e. cmd).
L: is NTFS.
Do you know if DOS has a different limit than Windows?

Richard Suchland <suchland>
Thu 24 Apr 2025 05:54:08 PM UTC, comment #8: 

If `cmd` doesn't list that file with `dir` either, I agree that it's likely not an issue with Octave.

How do you know that the file is there if it doesn't appear in `cmd` using `dir`?

Is L: a local drive? Is it a network drive? An entry point to a folder on another drive? Which file system does it use? NTFS? Something else?

I don't recall coming across a file name limit on Windows other than the maximum path length limit of approximately 260 characters by default. (That includes the whole absolute path.)
Newer versions of Windows offer modified API calls that expand that limit to approximately 32,767 characters. And Octave tries to use these newer API calls where possible.
But these 52 characters in a root directory of a drive isn't even close to the lower 260 character limit.

I don't know which issue you are hitting here...

Markus Mützel <mmuetzel>
Group administrator
Thu 24 Apr 2025 05:50:20 PM UTC, comment #7: 

Is "L:\" a physical partition on the hardddrive, or some kind of symbolic link, or remote share?
The "260" char limit apply to full filepath name, so it is possible that the fileserver has a very long share name that you have mounted ad "L:\".

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 24 Apr 2025 03:19:15 PM UTC, comment #6: 

Looks like my Windows is the problem.  I'm using the same version as Markus, so maybe a have a wrong setting.
dir "L:\123456789012345678901234567890123456789012345678901234567890.txt"
 Volume in drive L is ATARI (I)
 Volume Serial Number is 7235-4F2A

 Directory of L:\

File Not Found

L:\Octave\Atari\Dev4>dir "L:\12345678901234567890123456789012345678901234567890.txt"
 Volume in drive L is ATARI (I)
 Volume Serial Number is 7235-4F2A

 Directory of L:\

04/23/2025  06:01 PM                 0 12345678901234567890123456789012345678901234567890.txt
               1 File(s)              0 bytes
               0 Dir(s)  670,199,754,752 bytes free

Richard Suchland <suchland>
Thu 24 Apr 2025 03:09:37 PM UTC, comment #5: 


>>  fname = 'L:\123456789012345678901234567890123456789012345678901234567890.txt';
>> _wglob_ (fname)

ans = {}(0x0)

L:\123456789012345678901234567890123456789012345678901234567890.txt
is an empty file.  I don't think being empty should cause a problem since it works with the same file with a shorter name.

Richard Suchland <suchland>
Thu 24 Apr 2025 03:07:13 PM UTC, comment #4: 

I am using Windows 11 24H2 (OS Build 26.100.3775)

Richard Suchland <suchland>
Thu 24 Apr 2025 11:36:45 AM UTC, comment #3: 

Which version of Windows are you using?

I tried to reproduce on Windows 11 24H2. But it seems to be working with even longer file names:

>> ls('b')
ls: cannot access 'b': No such file or directory
>> system('touch 1234567890123456789012345678901234567890123456789012345678901234567890.txt')
ans = 0
>> copyfile('1234567890123456789012345678901234567890123456789012345678901234567890.txt', 'b')
>> ls('b')
b
>>


Markus Mützel <mmuetzel>
Group administrator
Thu 24 Apr 2025 10:51:13 AM UTC, comment #2: 

Just leave out the trailing question mark in the last command (oops)

Philip Nienhuis <philipnienhuis>
Group Member
Thu 24 Apr 2025 10:49:51 AM UTC, comment #1: 

Just to be sure:
do the files
'L:\1234567890123456789012345678901234567890.txt',
'L:\12345678901234567890123456789012345678901234567890.txt' and
'L:\123456789012345678901234567890123456789012345678901234567890.txt' really exist?
The error is generated in L.108, and when one follows the code in copyfile.m one can see that the error condition is generated if the relevant file cannot be found.

So, what do you get if you enter the commands:
fname = 'L:\123456789012345678901234567890123456789012345678901234567890.txt';
__wglob__ (fname) ?

Philip Nienhuis <philipnienhuis>
Group Member
Thu 24 Apr 2025 02:35:16 AM UTC, original submission:  

Executing copyfile with an input name greater than 52 characters fails. Example below:

copyfile('L:\1234567890123456789012345678901234567890.txt','b')
copyfile('L:\12345678901234567890123456789012345678901234567890.txt','b')
copyfile('L:\123456789012345678901234567890123456789012345678901234567890.txt','b')
error: copyfile: no files to move
error: called from
    copyfile at line 108 column 7
copyfile('L:\123456789012345678901234567890123456789012345678901.txt','b')
copyfile('L:\123456789012345678901234567890123456789012345678902.txt','b')
error: copyfile: no files to move
error: called from
    copyfile at line 108 column 7
# MAX_PATH, is defined as 260 characters

Richard Suchland <suchland>

 

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

Attach Files:
   
   
Comment:
   

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 rik5 (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by suchland (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-04-24 mmuetzel Summarysee below copyfile fails with very long file names on Windows
    2025-04-24 philipnienhuis StatusNone Need Info

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code