* Worked around our now POSIX conformant realpath() implementation. If we decide
to go back to BSD's, this one can be reverted again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31583 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -834,9 +834,31 @@ fileindir(const char *file, const char *dir)
|
|||||||
size_t dirlen;
|
size_t dirlen;
|
||||||
|
|
||||||
if (realpath(file, realfile) == NULL) {
|
if (realpath(file, realfile) == NULL) {
|
||||||
|
int error = 1;
|
||||||
|
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
/* Check if the parent directory exist which is all we need */
|
||||||
|
const char* last = strrchr(file, '/');
|
||||||
|
if (last != NULL) {
|
||||||
|
char parent[PATH_MAX+1];
|
||||||
|
strlcpy(parent, file, last - file);
|
||||||
|
|
||||||
|
if (realpath(parent, realfile) != NULL) {
|
||||||
|
strlcat(realfile, last, sizeof(realfile));
|
||||||
|
error = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* This already is the last component */
|
||||||
|
strlcpy(realfile, file, sizeof(realfile));
|
||||||
|
error = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
warn("Unable to determine real path of `%s'", file);
|
warn("Unable to determine real path of `%s'", file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (realfile[0] != '/') /* relative result */
|
if (realfile[0] != '/') /* relative result */
|
||||||
return 1;
|
return 1;
|
||||||
dirlen = strlen(dir);
|
dirlen = strlen(dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user