BUG: fix realpath problem and unix slashes

This commit is contained in:
Bill Hoffman 2004-10-05 10:59:07 -04:00
parent 1aab11b8db
commit 7f17646576

View File

@ -68,16 +68,15 @@ inline int Chdir(const char* dir)
return _chdir(dir); return _chdir(dir);
#endif #endif
} }
inline char *Realpath(const char *path, char *resolved_path) inline void Realpath(const char *path, kwsys_stl::string & resolved_path)
{ {
char *ptemp; char *ptemp;
char fullpath[MAX_PATH]; char fullpath[MAX_PATH];
if( GetFullPathName(path, sizeof(fullpath), fullpath, &ptemp) ) if( GetFullPathName(path, sizeof(fullpath), fullpath, &ptemp) )
{ {
return strcpy(resolved_path, fullpath); resolved_path = fullpath;
KWSYS_NAMESPACE::SystemTools::ConvertToUnixSlashes(resolved_path);
} }
return 0;
} }
#else #else
#include <sys/types.h> #include <sys/types.h>
@ -99,9 +98,20 @@ inline int Chdir(const char* dir)
{ {
return chdir(dir); return chdir(dir);
} }
inline char *Realpath(const char *path, char *resolved_path) inline void Realpath(const char *path, kwsys_stl::string & resolved_path)
{ {
return realpath(path, resolved_path); # ifdef MAXPATHLEN
char resolved_name[MAXPATHLEN];
# else
# ifdef PATH_MAX
char resolved_name[PATH_MAX];
# else
char resolved_name[5024];
# endif //PATH_MAX
# endif //MAXPATHLEN
realpath(path, resolved_name);
resolved_path = resolved_name;
} }
#endif #endif
@ -1550,23 +1560,12 @@ kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative,
{ {
dir = "/"; dir = "/";
} }
# ifdef MAXPATHLEN
char resolved_name[MAXPATHLEN];
# else
# ifdef PATH_MAX
char resolved_name[PATH_MAX];
# else
char resolved_name[5024];
# endif //PATH_MAX
# endif //MAXPATHLEN
// Resolve relative path. // Resolve relative path.
kwsys_stl::string newDir; kwsys_stl::string newDir;
if(!(dir == "")) if(!(dir == ""))
{ {
Realpath(dir.c_str(), resolved_name); Realpath(dir.c_str(), newDir);
newDir = resolved_name;
} }
else else
{ {