FAR editor executed by TotalCmd create undeletable files.

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

Post Reply
olesio
Junior Member
Junior Member
Posts: 54
Joined: 2009-01-22, 15:29 UTC
Location: Poland

FAR editor executed by TotalCmd create undeletable files.

Post by *olesio »

Hello. I reported a but at FAR file manager forum (link to my topic is: http://forum.farmanager.com/viewtopic.php?f=37&t=6491&p=82119#p82115) and bug report:
At start I want to say in version 1.70 of FAR everything was ok. But now when I try to use FAR Manager version 2.0 (build 1807) and Total Commander 7.56a under Windows 7 Ultimate 64 bit PL with SP 1 - I have following problem. In Total Commander settings for F4 key editor I have: C:\Program Files\FAR\far.exe -edit "%1" - and when I press under TotalCmd Shift + F4 and enter new file name WITHOUT ANY EXTENSION for example: pft (length is not important) and save new file (empty or not, but F2 or Escape when not empty do the same) the FAR create file under name "pft. " (filename + dot + space like dir command show it) and I can not delete or rename this file from Windows Explorer or Total Commander. The only temporary solution is set editor command in TotalCmd to: C:\Program Files\FAR\far.exe -edit %1 (no quotes before and after %1). But in this case when I want to create file: some long filename - I got visible name SOMELO~1 in editor. Another solution to delete undeleted file is rename it only under FAR to some correct name and delete it under FAR. Like I wrote in version 1.70 this problem does not exist. And I prefer to use TotalCmd but with viewer and editor from FAR.
I got answer:
DrKnS wrote:
olesio wrote:the FAR create file under name "pft. " (filename + dot + space like dir command show it)
Far creates exactly what it was asked for.
If you look at the command line of far.exe process (for example, using process exploper tool) you will see that tc provides file name as "pft. " instead of just "pft".
Far 1.70 works here only because it was a non-unicode program: when such program creates a file or directory windows silently removes all trailing dots and spaces from it's name.

So it's a bug in tc and there's nothing we can do.
You should contact their support to fix it.
So please fix this bug. Or if it is not a bug please tell me working solution. Total Commander should check when executing edior, and when a file extension is empty it should execute editor with onlnyfilename not onlyfilename. (with dot at end). The way of executing editor filename parameter with "%1" (with quotes) was suggested to me at this forum some time ago. Please answer. And sorry for my bad English.
Best regards: olesio
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Please note that TC doesn't add trailing space after dot. If I type pft as filename, TC passes to editor name as "pft." w/o trailing space. Default Windows functions remove last dots in filename and create files w/o extension at all if you use just dot at the end of filename. So all editors work fine with such names. AFAIK it adds dot in order to tell to Windows Notepad that file has no extension.

It is a FAR problem because it creates filenames with dots in case of empty extension. FAR uses special name prefix after which Windows doesn't remove dot and creates non-standard names - almost none of programs can work with such names.

So if you create file pft. in FAR it must remove trailing dot - trailing dots in filenames are non-standard.
olesio
Junior Member
Junior Member
Posts: 54
Joined: 2009-01-22, 15:29 UTC
Location: Poland

Post by *olesio »

Sorry maybe there was no space, but these ending dot caused problems. Like I wrote - in early FAR version 1.70 without UNICODE support everything was fine. Gouys from FAr forum asked me why I want to use TotalCmd + FAR. I answered FAR windows cannot be maximized on fullscreen and set to bigger fonts for person who have poor eyesight, like me. They recommend me ConEmu and it works fine I make small far_loader.exe in Delphi + WinAPI to execute FAR at full screen. Anyway, FAR have good editor and better than TotalCmd Registry plugin (in my opinion). But it strange, they say it is Total Commander bug, YOu say it is FAR. Anyway, this simple part of code in my far_loader.exe fix the bug:

Code: Select all

//...
            if AnsiLowerCase(FirstParam) = '-edit' then
            begin
              if (SecondParam <> '') then
              begin
                if SecondParam[Length(SecondParam)] = '.' then
                begin
                  Delete(SecondParam, Length(SecondParam), 1);
                end;
                ExecNewProcess(AppPath + ConEmu_Exec + ' /cmd ' +
                  AppPath + Far_Exec + #32 + FirstParam + #32 + '"' + SecondParam + '"', SW_SHOW);
              end;
//...
Best regards: olesio
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think it is a Windows bug because if you call CreateFile function with path like "C:\ptf.", it removes trailing spaces, dots etc. But if you call same function using Unicode prefix like "\\?\C:\ptf." (BTW this prefix is NOT necessary, it is necessary only when paths longer than 260 characters are used), function doesn't change name at all and creates file that may be accessed only using path with specified prefix - so if you use prefix, you get many problems. I don't understand at all why Windows uses such prefix - there is no length limt for null-terminating strings. But since FAR uses prefix it should manually remove trailing spaces and dots because such names are non-standard (even Windows Explorer can't access/rename files/folders with names that end with dots or spaces after extension) - no one expects to get file with dot at the end when writes something like "ptf.".

It is good that you can write simple tool that corrects path to file passed to editor.

However I prefer to use GUI editors in GUI operating system, they provide much better view, allow to copy/paste/drag-n-drop text etc. Also GUI programs allow to customize colors much better.
olesio
Junior Member
Junior Member
Posts: 54
Joined: 2009-01-22, 15:29 UTC
Location: Poland

Post by *olesio »

Ok, thank you for answers. I fortunately can make simple Delphi code and loads ConEmu + FAR or ConEmu + Hiew. Beacuse like I said, I have poor eyesight and I see my monitor from some distance not by siting at fron of it in desk. Also I got used to the look of FAR under Windows XP, when I was able to switch console Windows to full screen and see big font in resolution 80x25 lines. Now thanks to ConEmu I can have that. I did not find good simple (for me) editor in GUI, I just got used to FAR editor features and keyboard layout, so I use it associeted with F3 and F4 keys under Total Commander.
Best regards: olesio
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC has to add the space for some versions of notepad.exe, because without the space, notepad tries to create new file "ptf.txt" instead of accessing existing file "ptf".
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Maybe TC can detect if Microsoft's notepad.exe is used and apply such things only if it is so?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Unfortunately I cannot exclude that other programs have the same problem. Any Windows program which uses the _standard_ API functions will not have a problem with the dot at the end - only FAR seems to be misbehaving. :(
Author of Total Commander
https://www.ghisler.com
Post Reply