for those w/o this in libc
This commit is contained in:
@@ -104,7 +104,8 @@ char * realpath(old, new)
|
|||||||
* Resolve the last component of the path if it is a link
|
* Resolve the last component of the path if it is a link
|
||||||
* until it is a non-link.
|
* until it is a non-link.
|
||||||
*/
|
*/
|
||||||
while ((statbuf.st_mode & _S_IFMT) == _S_IFLNK) {
|
errno = 0;
|
||||||
|
while (!lstat(new, &statbuf) && (statbuf.st_mode & _S_IFMT) == _S_IFLNK) {
|
||||||
/* it's a link */
|
/* it's a link */
|
||||||
|
|
||||||
if ((len = readlink(new, buf, sizeof(buf))) <= 0)
|
if ((len = readlink(new, buf, sizeof(buf))) <= 0)
|
||||||
@@ -130,6 +131,10 @@ char * realpath(old, new)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* did an lstat() fail? */
|
||||||
|
if (errno)
|
||||||
|
return(realpath_ret(NULL, cwd));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* separate the last component from the rest of the path
|
* separate the last component from the rest of the path
|
||||||
* so we can do a getcwd() safely.
|
* so we can do a getcwd() safely.
|
||||||
@@ -155,7 +160,7 @@ char * realpath(old, new)
|
|||||||
/* append "/" and buf to new but watch for double '/' */
|
/* append "/" and buf to new but watch for double '/' */
|
||||||
len = strlen(new);
|
len = strlen(new);
|
||||||
if (len) {
|
if (len) {
|
||||||
temp = new + len;
|
temp = new + len - 1;
|
||||||
if (*temp != '/') {
|
if (*temp != '/') {
|
||||||
*(++temp) = '/';
|
*(++temp) = '/';
|
||||||
*(++temp) = '\0';
|
*(++temp) = '\0';
|
||||||
|
@@ -104,7 +104,8 @@ char * realpath(old, new)
|
|||||||
* Resolve the last component of the path if it is a link
|
* Resolve the last component of the path if it is a link
|
||||||
* until it is a non-link.
|
* until it is a non-link.
|
||||||
*/
|
*/
|
||||||
while ((statbuf.st_mode & _S_IFMT) == _S_IFLNK) {
|
errno = 0;
|
||||||
|
while (!lstat(new, &statbuf) && (statbuf.st_mode & _S_IFMT) == _S_IFLNK) {
|
||||||
/* it's a link */
|
/* it's a link */
|
||||||
|
|
||||||
if ((len = readlink(new, buf, sizeof(buf))) <= 0)
|
if ((len = readlink(new, buf, sizeof(buf))) <= 0)
|
||||||
@@ -130,6 +131,10 @@ char * realpath(old, new)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* did an lstat() fail? */
|
||||||
|
if (errno)
|
||||||
|
return(realpath_ret(NULL, cwd));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* separate the last component from the rest of the path
|
* separate the last component from the rest of the path
|
||||||
* so we can do a getcwd() safely.
|
* so we can do a getcwd() safely.
|
||||||
@@ -155,7 +160,7 @@ char * realpath(old, new)
|
|||||||
/* append "/" and buf to new but watch for double '/' */
|
/* append "/" and buf to new but watch for double '/' */
|
||||||
len = strlen(new);
|
len = strlen(new);
|
||||||
if (len) {
|
if (len) {
|
||||||
temp = new + len;
|
temp = new + len - 1;
|
||||||
if (*temp != '/') {
|
if (*temp != '/') {
|
||||||
*(++temp) = '/';
|
*(++temp) = '/';
|
||||||
*(++temp) = '\0';
|
*(++temp) = '\0';
|
||||||
|
Reference in New Issue
Block a user