Menu

#678 Stream Class add ~qualifylong method which will return the GetLongPathName

5.0.0
closed
Erich
None
none
1
2023-01-01
2016-10-07
mdlueck
No

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

Discussion

  • Erich

    Erich - 2016-10-07
     
  • Erich

    Erich - 2016-10-07

    support input of relative paths

    if starting from a long current directory and a long filename, qualify() should give you a long fully qualified path

    on Windows, the program end up with the short path version of the fully qualified file path

    Are 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 path

     
    • mdlueck

      mdlueck - 2016-10-07

      Greetings 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

       
  • Erich

    Erich - 2016-10-07

    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

    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 instead

     
    • mdlueck

      mdlueck - 2016-10-07

      Greetings 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

       
  • Erich

    Erich - 2016-10-09
    • status: unread --> pending
    • assigned_to: Erich
    • Milestone: None --> 5.0.0
     
  • Erich

    Erich - 2016-10-09

    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 a SysGetShortPathName function to rexxutil. 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]

  • Anonymous

    Anonymous - 2016-10-09

    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

     
  • Rony G. Flatscher

    • Status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel