I make use of the following ooRexx code to fully qualify user entered filenames. The intent is to in my program support input of relative paths, and for the program to be able to detirmin the fully qualified file path being requested.
/ Use the Object Rexx stream object / qualify method to do as much work as we can get it to do... /
FINDstream = .stream~new(FINDfilenamequery)
FINDfilename = FINDstream~qualify
drop FINDstream
As is, on Windows, the program end up with the short path version of the fully qualified file path.
According to this page:
Short vs. Long Names
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#short_vs._long_names
To get the 8.3 form of a long file name, use the GetShortPathName function.
To get the long file name version of a short name, use the GetLongPathName function.
So I would think it minimal work to add a ~qualifylong method to the Stream Class and have it make a call to GetLongPathName.
I suspect this issue exists only on the Windows platform, so on *nix platforms, could have ~qualifylong point to ~qualify
Anonymous
if starting from a long current directory and a long filename,
qualify()
should give you a long fully qualified pathAre you running from a current directory specified as 8.3 short-name? Or are 8.3 short-name being entered as filenames?
If so,
qualify()
quite reasonably will return the short fully qualified pathGreetings Erich,
For example looking up the value of the Temp environment variable, appending to that path a directory and filename, and then qualifying it... that ends up the 8.3 short path version. I propose adding a ~qualifylong which would return the Long Filename version of that same valid full path.
So in the case of obtaining full paths in the temp directory... the program is running from a program directory, needing to deal with temp files, so makes ~qualify calls to fully qualify / validate what it is attempting to do. Those fully qualified paths into the Temp directory are ending up 8.3 short-name.
I am thankful,
Michael
That should only happen if the value of your TEMP environment variable is set as a short 8.3 path, like
C:\Users\MICHAE~1\AppData\Local\Temp
If so, you might just want to set TEMP to e. g.
C:\Users\MichaelDLueck\AppData\Local\Temp
insteadGreetings Erich,
So again... if I were to update the Temp environment varialble on the user's behalf, I would still need an API to convert from the short name to the long name. ~qualifylong method to the rescue! ;-)
But actually, I would probably just leave the MS default, and use the ~qualifylong method in my programs / use of the variable.
I am thankful,
Michael
I don't think we should add a
qualifyLong
method.qualify
will qualify a path, no matter whether it exists or not,GetLongPathName
only accepts existing paths.I've added a
SysGetLongPathName
and aSysGetShortPathName
function torexxutil
. Both are Windows-only.Code committed with revision [r11170].
Tests committed with revision [r11171].
Doc updates committed with revision [r11172].
Related
Commit: [r11170]
Commit: [r11171]
Commit: [r11172]
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Greetings Erich,
"I've added a SysGetLongPathName and a SysGetShortPathName function to rexxutil."
Excellent alternative design. I like it. With the output of the Stream Class ~qualify, one can feed it into RexxUtil's new SysGetLongPathName to obtain the Long Path version.
I so appreicate you getting the API's added so quickly.
I am thankful,
Michael