Incorrect file length count in "long name" warning

Please report only one bug per message!

Moderators: Stefan2, sheep, white, Hacker

User avatar
Flint
Power Member
Power Member
Posts: 3141
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Incorrect file length count in "long name" warning

Post by Flint » 2017-11-27, 22:54 UTC

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, other stuff!
 
Using TC 9.20rc2 / Win7 x32 & x64 SP1

User avatar
Dalai
Power Member
Power Member
Posts: 6092
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by Dalai » 2017-11-28, 15:29 UTC

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

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

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

Post by ghisler(Author) » 2017-11-28, 15:40 UTC

Yes indeed, the 257 character is with the terminating 0, and the 256 too.
Author of Total Commander
http://www.ghisler.com

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

Post by ghisler(Author) » 2018-05-16, 16:49 UTC

This should finally be fixed in beta 3, please test it!
Author of Total Commander
http://www.ghisler.com

User avatar
Dalai
Power Member
Power Member
Posts: 6092
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by Dalai » 2018-05-16, 20:34 UTC

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
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
Flint
Power Member
Power Member
Posts: 3141
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Post by Flint » 2018-05-16, 22:57 UTC

I confirm what Dalai posted.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, other stuff!
 
Using TC 9.20rc2 / Win7 x32 & x64 SP1

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

Post by ghisler(Author) » 2018-05-17, 10:14 UTC

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
http://www.ghisler.com

User avatar
Flint
Power Member
Power Member
Posts: 3141
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Post by Flint » 2018-05-17, 13:23 UTC

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, other stuff!
 
Using TC 9.20rc2 / Win7 x32 & x64 SP1

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by MarcinW » 2018-05-17, 19:57 UTC

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: 35991
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by ghisler(Author) » 2018-05-18, 10:17 UTC

You get an error, that's sufficient.
Author of Total Commander
http://www.ghisler.com

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by MarcinW » 2018-05-18, 10:20 UTC

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: 35991
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by ghisler(Author) » 2018-05-21, 07:56 UTC

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
http://www.ghisler.com

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by MarcinW » 2018-05-22, 10:08 UTC

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: 35991
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by ghisler(Author) » 2018-05-23, 15:38 UTC

OK, I changed it in beta 4 to "Invalid name", please test it!
Author of Total Commander
http://www.ghisler.com

User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by MarcinW » 2018-05-24, 14:01 UTC

Problem solved. Thanks!

Post Reply