wreaddir_resolving: Don't add "/" for empty paths
This could end up trying to `stat()` a file in /, like "/glassdoor", if the dir_path was empty.
This commit is contained in:
parent
88e578a9ed
commit
8b9a051b93
@ -76,7 +76,11 @@ bool wreaddir_resolving(DIR *dir, const wcstring &dir_path, wcstring &out_name,
|
||||
if (check_with_stat) {
|
||||
// We couldn't determine the file type from the dirent; check by stat'ing it.
|
||||
cstring fullpath = wcs2string(dir_path);
|
||||
fullpath.push_back('/');
|
||||
if (!fullpath.empty()) {
|
||||
// If the dir_path was empty, we just use the name.
|
||||
// This ends up as a relative path which is fine.
|
||||
fullpath.push_back('/');
|
||||
}
|
||||
fullpath.append(result->d_name);
|
||||
struct stat buf;
|
||||
if (stat(fullpath.c_str(), &buf) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user