[WFX] FsGetFile and long paths

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: sheep, Hacker, Stefan2, white

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

[WFX] FsGetFile and long paths

Post by *Dalai » 2019-07-17, 20:55 UTC

Hi there,

I'm currently trying to add support for long paths to my plugins - or at the very least avoid them crashing with an exception. Since TC doesn't pass a path with a long path prefix (\\?\) to the plugin it's up to the plugin to do so. I was wondering if the plugin is allowed to return such a path to TC or it must not do so. The WFX plugin guide states:
LocalName
[...] The plugin may change the NAME/EXTENSION of the file (e.g. when file conversion is done), but not the path!
Well, technically when prepending LocalName with the long path prefix, I'm not changing the path. But I'm not sure whether or not I should return this prefixed path to TC.

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

Plugins: Services2, Startups

User avatar
MVV
Power Member
Power Member
Posts: 8389
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: [WFX] FsGetFile and long paths

Post by *MVV » 2019-07-18, 06:41 UTC

I think you shouldn't modify LocalName, especially if you don't know buffer size. I prefer to treat RemoteName/LocalName as const pointers.
You always can make a prefixed copy of LocalName if you need to pass prefixed path to API (I don't think that anyone will use UNC path for TEMP folder, but in such case you will have to copy path anyway due to the non-standard transformation of UNC path to a prefixed one).

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

Re: [WFX] FsGetFile and long paths

Post by *ghisler(Author) » 2019-07-18, 09:27 UTC

You shouldn't prepend \\?\ to paths returned to TC. Just return the longer path, TC will add it itself when necessary to access the file.
Author of Total Commander
http://www.ghisler.com

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

Re: [WFX] FsGetFile and long paths

Post by *Dalai » 2019-07-18, 13:30 UTC

2ghisler(Author)
OK, thanks!

2MVV
Yes, I'm working with string copies already, so it's not an issue at all. The question was just to decide where to put the long path prefixing in FsGetFile function - before or after returning the changed path to TC. BTW: FsGetFile is not only used when viewing a file (in which case the file is saved to %TEMP% dir) but also for downloading files via F5. So, I have to consider long UNC paths as well.

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

Plugins: Services2, Startups

Post Reply