* 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:
Axel Dörfler
2009-07-15 11:31:44 +00:00
parent 648b674d3f
commit 491e89c541
+24 -2
View File
@@ -834,8 +834,30 @@ fileindir(const char *file, const char *dir)
size_t dirlen;
if (realpath(file, realfile) == NULL) {
warn("Unable to determine real path of `%s'", file);
return 0;
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);
return 0;
}
}
if (realfile[0] != '/') /* relative result */
return 1;