This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: canonicalize_file_name


John Emmas> Calling 'canonicalize_file_name(path)' is equivalent to calling
JE> 'realpath(path, NULL)'   By a stroke of luck, 'realpath()' is defined in
JE> cygwin/stdlib.h so maybe I should use that?

Corinna Vinschen> Yes, sure.

Yes, you should use realpath(), but passing it NULL won't necessarily
work.  The second argument is supposed to be a pointer to the buffer
in which it should put its result, and according to POSIX the call
should fail if that argument is NULL.

GNU has extended its version of realpath() to dynamically allocate a
result buffer when the second argument is NULL.  I would not assume
that Cygwin does likewise, since it's a libc function and Cygwin
doesn't use GNU libc.  The safest course would be to declare or
preallocate a buffer of size PATH_MAX and pass it to realpath(); that
should work with any POSIX-compliant C library.

-- 
Mark J. Reed <markjreed@gmail.com>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]