diff --git a/common/file.cpp b/common/file.cpp index 55779b98..5a639b85 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -12,8 +12,11 @@ static void Resolve_File_Single(char* fname) return; } - if (ffblk->FindFirst(fname) && strlen(fname) == strlen(ffblk->GetName())) { - strncpy(fname, ffblk->GetName(), strlen(fname) + 1); + size_t name_len = strlen(fname); + size_t full_len = strlen(ffblk->GetFullName()); + + if (ffblk->FindFirst(fname) && name_len == full_len) { + strncpy(fname, ffblk->GetFullName(), name_len + 1); } delete ffblk; diff --git a/common/file.h b/common/file.h index 83b447ff..3e05794c 100644 --- a/common/file.h +++ b/common/file.h @@ -231,6 +231,10 @@ class Find_File_Data { } virtual const char* GetName() const = 0; + virtual const char* GetFullName() const + { + return nullptr; + }; virtual unsigned int GetTime() const = 0; virtual bool FindFirst(const char* fname) = 0; diff --git a/common/file_posix.cpp b/common/file_posix.cpp index 233ba0f9..bcc4d64e 100644 --- a/common/file_posix.cpp +++ b/common/file_posix.cpp @@ -18,6 +18,10 @@ class Find_File_Data_Posix : public Find_File_Data virtual ~Find_File_Data_Posix(); virtual const char* GetName() const; + virtual const char* GetFullName() const + { + return DirEntry != nullptr ? FullName : nullptr; + } virtual unsigned int GetTime() const; virtual bool FindFirst(const char* fname); @@ -50,7 +54,7 @@ const char* Find_File_Data_Posix::GetName() const if (DirEntry == nullptr) { return nullptr; } - return FullName; + return DirEntry->d_name; } unsigned int Find_File_Data_Posix::GetTime() const