OS/2, eCS & ArcaOS - Technical > Programming

Fully qualified file specifications (of any valid file name argument)

(1/2) > >>

xynixme:
Is there an API which converts any valid file specification of an user to a fully qualified path. Like, assuming all are valid and the current working directory in C:\OS2:

FOO.BAR
\FOO.BAR
.\FOO.BAR
.\BITMAP\..\FOO.BAR
..\FOO.BAR
\\SERVER\OS2\FOO.BAR
C:FOO.BAR
C:\OS2\FOO.BAR

You can assume that the file FOO.BAR was created successfully earlier, by using fopen(). So if \\SERVER\OS2\FOO.BAR will never work, then you can skip that one. A Win*() API requires a fully qualified path, but an user could have entered anything that'll work with fopen(). So all I may know is "FOO.BAR".

Or do I have to check if there'a a "\". If so, "CHDIR" to it and query that current drive and directory?

Andreas Schnellbacher:
DosQueryPathInfo with FIL_QUERYFULLNAME. I don't know if it handles UNC names.

xynixme:
Thank you, that wasn't hard to apply.

Since failure is an option, I've taken care of UNCs by checking that the 2nd character is a ":". The API does understand specs like NUL, which expands to \DEV\NUL, so if an user with a network is lucky then e.g. \\SERVER\BMP\ECS24.BMP will be converted to O:\BMP\ECS24.BMP.

Andreas Schnellbacher:
Thanks for testing and reporting the behavior with UNC names.

xynixme:

--- Quote from: Andreas Schnellbacher on September 03, 2019, 09:38:08 pm ---Thanks for testing and reporting the behavior with UNC names.
--- End quote ---

I cannot test UNC names, but there should be 3 possibilities if an UNC is \\SERVER\2019\FILENAME.CMD:

1. API returns \\SERVER\2019\FILENAME.CMD, not being a fully qualified file name for an OS/2 object
2. API returns \\SERVER\2019\FILENAME.CMD, possibly a fully qualified file name for an OS/2 object
3. API returns P:\WAN\Accounting\2019\FILENAME.CMD, certainly a fully qualified file name for an OS/2 object
4. API's input is NUL, API returns \DEV\NUL

Since I cannot test (2), checking for a ":" as a second character is the-best-of-the-rest if the file has to be real. IOW, not a device pretending to be an existing file.

Navigation

[0] Message Index

[#] Next page

Go to full version