Incorrect file length count in "long name" warning

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Incorrect file length count in "long name" warning

Post by *Flint »

1. Create a file with some short name.
2. Try to rename it into exactly 256-character length name.
3. TC displays the warning dialog:
The target name length (264) is more than 259 characters!
Additionally, the last part of the name is 257 characters long, which is longer than the maximum possible 256 characters!
Problems:
* First, it claims the file name length is 257 characters instead of actual 256.
* Second, it says the maximum possible length is 256 characters, but does not allow to create such a file.

According to NTFS specifications, the maximum possible length is actually 255 characters, so that explains why 256-chars file name cannot be created, but the translation line 1699 should then look like "…longer than the maximum possible 255 characters!".

P.S. Maybe TC takes into account the trailing zero byte, but from the users' point of view it's not obvious.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

I can confirm both issues. This also applies to TC 8.52a.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes indeed, the 257 character is with the terminating 0, and the 256 too.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This should finally be fixed in beta 3, please test it!
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Well, the incorrect count issue is fixed, but another closely related one is still present. Making the name exactly 256 characters long (name including extension and the separating dot!) shows the error message

Code: Select all

---------------------------
Total Commander
---------------------------
Error: Cannot write H:\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...!

Please remove the write protection!
---------------------------
OK   Abbrechen   
---------------------------
Making the name one character shorter works OK, and when making it one character longer (257 chars) TC shows the confirmation of whether to keep the long name (also mentioned in the OP).

Looks to me like some comparison (if-statement) uses an incorrect number.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

I confirm what Dalai posted.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

That's because the path name isn't longer than the Windows limit of 259 characters, but the individual name within the directory is longer than 255 characters. Since it's impossible to create such names even with the prefix, TC shows a rename error directly.
Author of Total Commander
https://www.ghisler.com
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

I see what you mean, I forgot that the dialog's intention is to warn about long paths, not about long names.

But come to think of it, maybe it's better to show the specific message to user instead of generic "Cannot write"? Because now the user might remain confused about what happened. TC says, "Please remove the write protection!", but there is no write protection.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Same observations here.

When trying to create a file name having 257 chars, we always get a warning (because even drive prefix alone will make the path longer than 259 chars).

When trying to create a file name having 256 chars in any directory, we always get a warning (because drive prefix + even shortest directory name will make the path longer than 259 chars).

When trying to create a file name having 256 chars in a root directory, we get no warning (because drive prefix alone will make the path having exactly 259 chars).

And the last case is confusing - we get only "cannot write" error. The best solution would be to warn also in the last case - with a shorter warning text, informing only about too long name (not the whole path). This is what every user expects, I think.

Since the user sees a warning about too long name and too long path, he doesn't expect, that path length is the only factor, that is taken into consideration when launching the warning window.

Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You get an error, that's sufficient.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Ok. So please make the error message more meaningful! "Cannot write... Please remove the write protection!" is highly confusing.

Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The reason why I don't do this: The 259 character limit per path and the 255 character limit are two completely different things:
1. The 259 character limit is a limit of Windows functions like CreateFile, DeleteFile etc. It means that when you create a file with a longer name, it can only be accessed with a trick (by putting \\?\ or \\?\UNC\ in front of the name). Most Windows program do not use this workaround, so they will be unable to access these files.

2. The 255 character limit per name within a directory is a limit specific to the NTFS file system. Other file system may have other limits. For example, the FAT file system limits the number of files in the root of a drive, because the root is stored in a fixed location and not as a (growable) file. Therefore the hint about the 255 character limit is just a hint, it doesn't mean that creating such a file will fail in every case. There may be file systems where such a name would actually be allowed. Therefore TC allows to try to create such a file.

Howerver, it's a good idea to report "Invalid file name" in this case.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

ghisler(Author) wrote:However, it's a good idea to report "Invalid file name" in this case.
Thanks!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I changed it in beta 4 to "Invalid name", please test it!
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Problem solved. Thanks!
Post Reply