Any alternate to GetFullPathName() to work on Unix

S

saurabh

Hi,
Is there any POSIX function for GetFullPathName() API
I require to run a code using this on Unix.
Thanks in advance.
 
F

Fred Zwarts

saurabh said:
Hi,
Is there any POSIX function for GetFullPathName() API
I require to run a code using this on Unix.
Thanks in advance.

Maybe, if you explain what GetFullPathName is supposed to do.
 
J

Jim Langston

Fred Zwarts said:
Maybe, if you explain what GetFullPathName is supposed to do.

MSDN says that GetFullPathName returns the full path and filename of the
specified file.
 
J

James Kanze

MSDN says that GetFullPathName returns the full path and
filename of the specified file.

Presumably, it also does some minimal form of canonization. It
doesn't really justify a system function to just concatenate
getcwd() and a filename (with a '/') between them. But if the
file name is something like "../../x/y/z.cc", you probably don't
want the results to be "/home/kanze/x/y/../../x/y/z.cc". (The
Microsoft documentation---at least that that I found---is a
model of underspecification; it really doesn't say anything
about the results.)

Under Unix, there's also the question of what to do about links
(symbolic or otherwise): under Unix, a filename may very easily
have several "full pathnames" (or in some special cases, none).
So the function doesn't necessarily make sense.
 
J

James Kanze

saurabh writes:
Yes. realpath().

Before saying that, it would be interesting to know what
GetFullPathName() actually does. Does it `canonize'?
(realpath() does.) Does it resolve symbolic links. realpath()
does, and of course, Windows only has symbolic links since
Vista? (But what does GetFullPathName() do with short cuts?)

Note too that realpath() has a broken interface, which makes it
impossible to use in a correct program except in restricted
cases. At least, I was unable to find a way. Basically, it
requires that you provide a buffer of PATH_MAX bytes. but
PATH_MAX depends on the file system, and the file system depends
on the real path---you need the results of realpath() in order
to determine PATH_MAX. (I ended up re-implémenting it myself,
so that it would work robustly.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top