Page 1 of 2

Incorrect file length count in "long name" warning

Posted: 2017-11-27, 22:54 UTC
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.

Posted: 2017-11-28, 15:29 UTC
by Dalai
I can confirm both issues. This also applies to TC 8.52a.

Regards
Dalai

Posted: 2017-11-28, 15:40 UTC
by ghisler(Author)
Yes indeed, the 257 character is with the terminating 0, and the 256 too.

Posted: 2018-05-16, 16:49 UTC
by ghisler(Author)
This should finally be fixed in beta 3, please test it!

Posted: 2018-05-16, 20:34 UTC
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

Posted: 2018-05-16, 22:57 UTC
by Flint
I confirm what Dalai posted.

Posted: 2018-05-17, 10:14 UTC
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.

Posted: 2018-05-17, 13:23 UTC
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.

Posted: 2018-05-17, 19:57 UTC
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

Posted: 2018-05-18, 10:17 UTC
by ghisler(Author)
You get an error, that's sufficient.

Posted: 2018-05-18, 10:20 UTC
by MarcinW
Ok. So please make the error message more meaningful! "Cannot write... Please remove the write protection!" is highly confusing.

Regards

Posted: 2018-05-21, 07:56 UTC
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.

Posted: 2018-05-22, 10:08 UTC
by MarcinW
ghisler(Author) wrote:However, it's a good idea to report "Invalid file name" in this case.
Thanks!

Posted: 2018-05-23, 15:38 UTC
by ghisler(Author)
OK, I changed it in beta 4 to "Invalid name", please test it!

Posted: 2018-05-24, 14:01 UTC
by MarcinW
Problem solved. Thanks!