From: SourceForge.net <no...@so...> - 2005-12-14 13:21:01
|
Patches item #1294010, was opened at 2005-09-17 19:29 Message generated for change (Comment added) made by n-a-c-h You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=302435&aid=1294010&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: runtime Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nach M. S. (n-a-c-h) Assigned to: Nobody/Anonymous (nobody) Summary: Full implementation of realpath() for Win32 Initial Comment: I noticed the other day that Win32 is the only port one of my applications doesn't have access to realpath() on. So I wrote realpath() for it, and I might as well submit it so it becomes part of MinGW and I don't have to make a special ifdef __WIN32__ for it ;) The realpath() I wrote should be standards conforming. It uses GetFullPathNameA() from Win32 as the underlying means as getting the resolved path. It sets errno appropriately as needed and even translates Win32 errors to the appropriate errno. It also makes sure the path exists (via a call to stat()) and supports the glibc extension to allocate the resolved path buffer if it was passed in as null to the call to realpath(). My tests show the function works quite well, but if someone finds an error with it, I'll be happy to fix it. I give full permission to MinGW and it's users to use it, if I messed up on the usage rights in the file, I'll be happy to change it too. -Nach ---------------------------------------------------------------------- >Comment By: Nach M. S. (n-a-c-h) Date: 2005-12-14 13:20 Message: Logged In: YES user_id=695796 >Hmm. I normally just use > > #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) > >if I need realpath(). > >_fullpath() is a standard Microsoft function, which >somewhat >more closely resembles realpath() than GetFullPathNameA() >does, although it still doesn't confirm that the >referenced >entity either exists, or is accessible. > >If you want a somewhat more SUSv3 conformant implementation >of realpath(), you might consider the more compact version >I've attached. That's very nice, but your implementation isn't standards conformant, close doesn't cut it. The one I've written makes sure the entity does exist and is accessable. Mine also sets errno properly. >in the case of a function such as realpath(), which is not >a standard Microsoft function, and therfore not documented >on MSDN, I would also like to see documentation, preferably >in the form of a manpage I thought you have access to the manpage for realpath, I'm attaching the Linux one I have which is basically what I cloned. >and any peculiarities of its behaviour in it's Win32 >adaptation. In the case of Win32, the ELOOP won't ever be returned by my implementation since it doesn't do any checks for symbolic links. As far as I know, Win32 currently doesn't use symbolic links. >You should also include a patch, in `diff -u' format, to >add a suitable function prototype to an appropriate header >file. Not a problem. --- /usr/i586-mingw32/include/stdlib.h 2004-09-28 22:56:17.000000000 +0200 +++ stdlib.h 2005-12-14 15:25:07.000000000 +0200 @@ -407,6 +407,7 @@ _CRTIMP void __cdecl _makepath (char*, const char*, const char*, const char*, const char*); _CRTIMP void __cdecl _splitpath (const char*, char*, char*, char*, char*); _CRTIMP char* __cdecl _fullpath (char*, const char*, size_t); +_CRTIMP char* __cdecl realpath(const char *path, char resolved_path[PATH_MAX]); _CRTIMP char* __cdecl _itoa (int, char*, int); _CRTIMP char* __cdecl _ltoa (long, char*, int); >Also note that, when you assign software to the public >domain, then you implicitly relinquish any claim to >copyright over that code. Thus, the preamble to your code >should not claim copyright, while also asserting assignment >to the public domain; rather say `Public domain software: >written by M.S. Nach', or words to that effect, if you >wish to be identified as the author, or simply donate it >anonymously. Fine, I'll resubmit the file with a different header. -Nach ---------------------------------------------------------------------- Comment By: Keith Marshall (keithmarshall) Date: 2005-12-02 21:50 Message: Logged In: YES user_id=823908 Hmm. I normally just use #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) if I need realpath(). _fullpath() is a standard Microsoft function, which somewhat more closely resembles realpath() than GetFullPathNameA() does, although it still doesn't confirm that the referenced entity either exists, or is accessible. If you want a somewhat more SUSv3 conformant implementation of realpath(), you might consider the more compact version I've attached. Thanks for your patch, but I will not add it to MinGW in its present form. Note that for formal consideration, patches should be accompanied by an appropriate ChangeLog entry; in the case of a function such as realpath(), which is not a standard Microsoft function, and therfore not documented on MSDN, I would also like to see documentation, preferably in the form of a manpage, describing the function's usage, and any peculiarities of its behaviour in it's Win32 adaptation. You should also include a patch, in `diff -u' format, to add a suitable function prototype to an appropriate header file. Also note that, when you assign software to the public domain, then you implicitly relinquish any claim to copyright over that code. Thus, the preamble to your code should not claim copyright, while also asserting assignment to the public domain; rather say `Public domain software: written by M.S. Nach', or words to that effect, if you wish to be identified as the author, or simply donate it anonymously. Regards, Keith. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=302435&aid=1294010&group_id=2435 |