Ini files in wrong directory (because of Polish letter?)

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

krasusczak
Senior Member
Senior Member
Posts: 282
Joined: 2011-09-23, 10:35 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *krasusczak »

Hello,

I tested now (Win10+TC9.22a)
I created windows .lnk file with Polish & Russian characters & both fail:

C:\Users\Paweł\TotalCMD\TOTALCMD.EXE -i="c:\Users\Paweł\TotalCMD\wincmd.ini" -f="c:\Users\Paweł\TotalCMD\wcx_ftp.ini"
C:\Users\Павел\TotalCMD\TOTALCMD.EXE -i="c:\Users\Павел\TotalCMD\wincmd.ini" -f="c:\Users\Павел\TotalCMD\wcx_ftp.ini"

from command line same, TCM reports in "About":
c:\Users\Pawel\TotalCMD\wincmd.ini
c:\Users\Pawel\TotalCMD\wcx_ftp.ini
&
c:\Users\?????\TotalCMD\wincmd.ini
c:\Users\?????\TotalCMD\wcx_ftp.ini

if you have info in the registry: IniFileName it's exactly the same, & what is interesting if you have registry info & you run tc951rc4 installation you will get also error during installation: "Could not create ini file dir! The ini file location will not be saved" even if the is already folder...


but
"c:\Program Files (x86)\TotalCMD\TOTALCMD.EXE" -i="c:\Program Files (x86)\TotalCMD\wincmd.ini" -f="c:\Program Files (x86)\TotalCMD\wcx_ftp.ini"
works fine
Mooschka
Junior Member
Junior Member
Posts: 6
Joined: 2020-02-26, 06:42 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *Mooschka »

ghisler(Author) wrote: 2020-03-06, 16:37 UTC So only the installer fails to run from a subdir of C:\Users\Paweł, but Total Commander then runs fine when the settings are under C:\Users\Paweł?
I created new account "Pawełek", because "Paweł" and "pawel" is the same after convert ł to latin l.

1. Installation failed to start from location: c:\Users\Pawełek\Downloads\tcmd950x64.exe.
2. Installation completed from c:\Users\Public\Desktop\tcmd950x64.exe, but error "Could not create program group!" and user home directory recognized as c:\Users\Pawelek\
3. After installation, Total Commander start as regular user failed to save settings to file:
Error: Cannot write
C:\Users\Pawelek\AppData\Roaming\GHISLER\wincmd.ini!
Please remove this write protection!
4. Total Commander started as admin saved settings to c:\Users\Pawelek\AppData\Roaming\GHISLER\wincmd.ini.
5. regedit: IniFileName=%APPDATA%\GHISLER\wincmd.ini
6. cmd console:
C:\Users\Pawełek>echo %appdata%
C:\Users\Pawełek\AppData\Roaming
browny
Senior Member
Senior Member
Posts: 288
Joined: 2007-09-10, 13:19 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *browny »

ghisler(Author) wrote: 2020-02-26, 09:47 UTC This only works when setting the user locale to Poland for non-Unicode programs. Otherwise the ł isn't part of the codepage and cannot be used in ANSI INI file functions. This cannot be fixed on my side.
Did you consider using GetShortPathName function?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *ghisler(Author) »

I created windows .lnk file with Polish & Russian characters & both fail:

C:\Users\Paweł\TotalCMD\TOTALCMD.EXE -i="c:\Users\Paweł\TotalCMD\wincmd.ini" -f="c:\Users\Paweł\TotalCMD\wcx_ftp.ini"
C:\Users\Павел\TotalCMD\TOTALCMD.EXE -i="c:\Users\Павел\TotalCMD\wincmd.ini" -f="c:\Users\Павел\TotalCMD\wcx_ftp.ini"
from command line same, TCM reports in "About":
c:\Users\Pawel\TotalCMD\wincmd.ini
c:\Users\Pawel\TotalCMD\wcx_ftp.ini
I just tried creating such a link file myself - here the about box reports the correct name with the ł. When I check it in the debugger, I get the path as UTF-8.
1. Installation failed to start from location: c:\Users\Pawełek\Downloads\tcmd950x64.exe.
How did you launch the download? I tried various ways:
1. Downlaoded from Edge, started installer from it -> works
2. Downlaoded from Chrome, started installer from it -> works
3. Downlaoded from Firefox, started installer from it -> works
4. Started any of these downloads from Windows Explorer -> works

Also the program runs just fine afterwards.
Did you consider using GetShortPathName function?
There is no need, the short name passed to TC by Windows is already in UTF-8. For some unknown reasons, this doesn't work for user krasusczak.

2krasusczak.
Maybe it's a bug in older Windows 10 versions? Can you tell me which one you use? I use the latest release version 1903.
You can check that via menu
Commands - System information - Software - ProductId.
Author of Total Commander
https://www.ghisler.com
krasusczak
Senior Member
Senior Member
Posts: 282
Joined: 2011-09-23, 10:35 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *krasusczak »

ghisler(Author) wrote: 2020-03-09, 11:31 UTC
2krasusczak.
Maybe it's a bug in older Windows 10 versions? Can you tell me which one you use? I use the latest release version 1903.
You can check that via menu
Commands - System information - Software - ProductId.
I have newest one 1903
browny
Senior Member
Senior Member
Posts: 288
Joined: 2007-09-10, 13:19 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *browny »

ghisler(Author) wrote: 2020-03-09, 11:31 UTC
Did you consider using GetShortPathName function?
There is no need, the short name passed to TC by Windows is already in UTF-8. For some unknown reasons, this doesn't work for user krasusczak.
Is that correct about UTF-8? Windows internally and in W-suffixed functions uses UTF-16 LE, while A-suffiexed funcitons use ANSI/OEM.
Generated short names should be ASCII-only, and it could be checked with dir /x.

An alternative to GetShortPathName might be be PathGetShortPath function.

By the way, the latest Windows 10 is 1909 (18363).
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Ini files in wrong directory (because of Polish letter?)

Post by *MVV »

Is it correct to rely on short names in 2020 when modern systems allow disabling them completely? I still think that most reliable way is using W-functions with UTF-16 paths.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *ghisler(Author) »

Sorry, it's indeed 1909 here. I will test with 1903.
Is that correct about UTF-8? Windows internally and in W-suffixed functions uses UTF-16 LE, while A-suffiexed funcitons use ANSI/OEM.
Yes, when the above mentioned UTF-8 option is set, then the codepage for ANSI and OEM are both set to 65001, which is UTF-8. All conversions from ANSI to Unicode and vice versa will convert UTF-16 from/to UTF-8.
Is it correct to rely on short names in 2020 when modern systems allow disabling them completely?
There is no warning from Microsoft that these functions are deprecated. The A and W functions are equally well suited.
Author of Total Commander
https://www.ghisler.com
browny
Senior Member
Senior Member
Posts: 288
Joined: 2007-09-10, 13:19 UTC

Re: Ini files in wrong directory (because of Polish letter?)

Post by *browny »

ghisler(Author) wrote: 2020-03-10, 07:22 UTC All conversions from ANSI to Unicode and vice versa will convert UTF-16 from/to UTF-8.
According to this discussion UTF-8 and Win32 ANSI APIs, system code page should be set to 65001 (UTF-8).
I am losing perspective, how this might help with Windows 95 compatibility. :)
User avatar
Dalai
Power Member
Power Member
Posts: 9389
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Ini files in wrong directory (because of Polish letter?)

Post by *Dalai »

ghisler(Author) wrote: 2020-03-10, 07:22 UTCSorry, it's indeed 1909 here. I will test with 1903.There is no warning from Microsoft that these functions are deprecated.
It's not about the API functions. Short names may be disabled on all NTFS volumes: https://support.microsoft.com/en-us/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions

As the article describes, this can also be done on a per-volume basis, i.e. short names may be enabled on one volume but not on others.

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
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *DrShark »

I can confirm on Windows 7 32-bit TC started like:
%commander_exe% /I=c:\totalcmd\test\Paweł\test.ini
will create a new c:\totalcmd\test\Pawel\ dir with ini file inthere which TC will use.

The short name of "Paweł" dir doesn't have "ł" character as part of name (it's "pawe~1" here).

Short DOS names of course won't work on drives or file systems where 8.3 names disabled or not available, but at least this way TC could support more systems. There are some other situations (example) where using 8.3 names could solve the problems caused by some characters present in long file names.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *ghisler(Author) »

OK, I have put quite a lot of work into this problem in RC5. The following should work now:
1. The installer can now work from a Unicode directory, even if it doesn't have an 8.3 name.
2. When 8.3 name creation is enabled, TC will use the 8.3 name of the user profile
3. If 8.3 names are disabled, the user will be informed that the ini location couldn't be used. I recommend using a local directory like c:\totalcmd in such a case.

What doesn't work:
1. TC must not be installed in a Unicode only directory.
2. INI files in a Unicode only directory will not work when 8.3 names are disabled. While I could use the Unicode INI functions, the same path is also used by many plugins, including many of my own. They currently all use ANSI functions. They will receive the 8.3 name too, so it should work in that case.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *DrShark »

In my brief test TC 9.51 RC5 uses path with 8.3 names when started as:
%commander_exe% /I=c:\totalcmd\test\Paweł\test.ini
ghisler(Author) wrote: 2020-03-11, 18:26 UTC3. If 8.3 names are disabled, the user will be informed that the ini location couldn't be used. I recommend using a local directory like c:\totalcmd in such a case.
The history.txt mentions c:\temp, so what one is really recommended? Is it safe to recommend one with "temp" as a name for storing ini files (it may be used for storing really temporarily files like *.tmp, and set on some cleanup task)?
ghisler(Author) wrote: 2020-03-11, 18:26 UTC1. TC must not be installed in a Unicode only directory.
Does here "Unicode only" mean a Unicode long name without 8.3 short name alias, or any directory name with characters from a codepage different to system one? What will not work if to put TC files in such directory manually?

Also as I see, TC doesn't use 8.3 name for ini file itself if it has a long name with characters from a different codepage, so it seems ANSI only names are allowed for ini files. Is this intentional?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *ghisler(Author) »

The history.txt mentions c:\temp
This is an error in history.txt.
Does here "Unicode only" mean a Unicode long name without 8.3 short name alias, or any directory name with characters from a codepage different to system one?
It means any directory name with characters from a codepage different to system one. Many functions to access internal TC files still use ANSI. It would take months to rewrite them all.
Also as I see, TC doesn't use 8.3 name for ini file itself if it has a long name with characters from a different codepage, so it seems ANSI only names are allowed for ini files. Is this intentional?
Indeed INI files cannot have Unicode names because the functions to read from ANSI INI files expects an ANSI name for the ini file too.
Author of Total Commander
https://www.ghisler.com
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: Ini files in wrong directory (because of Polish letter?)

Post by *DrShark »

ghisler(Author) wrote: 2020-03-12, 10:20 UTC
Does here "Unicode only" mean a Unicode long name without 8.3 short name alias, or any directory name with characters from a codepage different to system one?
It means any directory name with characters from a codepage different to system one. Many functions to access internal TC files still use ANSI. It would take months to rewrite them all.
Also as I see, TC doesn't use 8.3 name for ini file itself if it has a long name with characters from a different codepage, so it seems ANSI only names are allowed for ini files. Is this intentional?
Indeed INI files cannot have Unicode names because the functions to read from ANSI INI files expects an ANSI name for the ini file too.
If TC dir, or the ini files have 8.3 short aliases, could the ANSI functions access TC dir and ini files by their 8.3 names? Or such functions need the rewriting for adding this Unicode name->8.3 name fallback?
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply