Skip to content

fix: FileSystemStd::GetFileDateAndSize forgets to use stringToPath() to create fs::path #231

@hazukihh

Description

@hazukihh

Forget to use stringToPath(vFilePathName) may cause fs::last_write_time(fpath) to trigger an error when the file path contains Unicode characters on the Windows platform.

void FileSystemStd::GetFileDateAndSize(const std::string& vFilePathName, const IGFD::FileType& vFileType, std::string& voDate, size_t& voSize) override {
  namespace fs = std::filesystem;
  try {
      // orignin
      // fs::path fpath(vFilePathName);

      // after FIX 
      fs::path fpath = stringToPath(vFilePathName);
      
      size_t len{};
      const auto lastWriteTime = fs::last_write_time(fpath); // origin code Will Error here

      /// codes...
  } catch (const fs::filesystem_error& ex) {
      voSize = 0;
      voDate.clear();
      IGFD_COUT << "IGFD : " << ex.what() << std::endl;
  }
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions