Index: source/lib/file/file_system.cpp =================================================================== --- source/lib/file/file_system.cpp +++ source/lib/file/file_system.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -27,13 +27,11 @@ #include "precompiled.h" #include "lib/file/file_system.h" -#include -#include -#include - #include "lib/sysdep/filesystem.h" +#include "ps/CLogger.h" #include +#include bool DirectoryExists(const OsPath& path) { @@ -120,7 +118,15 @@ errno = 0; const OsPath pathname = path / name; if(wstat(pathname, &s) != 0) + { + if (errno == ENOENT) + { + LOGWARNING("%s is a dangling symbolic link", + (path / name).string8().c_str()); + continue; + } WARN_RETURN(StatusFromErrno()); + } #endif if(files && S_ISREG(s.st_mode)) Index: source/lib/sysdep/os/win/wposix/wfilesystem.cpp =================================================================== --- source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -102,8 +102,8 @@ return true; } - -WDIR* wopendir(const OsPath& path) +// Return nullptr on error. +[[nodiscard]] WDIR* wopendir(const OsPath& path) { WinScopedPreserveLastError s; @@ -134,6 +134,12 @@ // always copying the large WDIR or findData from a temporary) wdir_free(d); + if (ErrnoFromStatus(status) == ENOENT) + { + LOGWARNING("%s is a dangling symbolic link", path.string8().c_str()); + errno = ENOENT; + return nullptr; + } WARN_IF_ERR(status); errno = ErrnoFromStatus(status);