I need to copy file from any location to the project folder (smth like Import action for resources/assets), that's why I use std::filesystem::copy/copy_file for this purpose. Then I've faced problems with the lib.
So, Filesystem fills m_FileList during initialization step. If I add a new file after this step and then try to OpenFile with mode Read it will fall into this piece of code:
IFilePtr file = FindFile(filePath, m_FileList);
bool isExists = (file != nullptr);
if (!isExists && !IsReadOnlyST()) {
mode = mode | IFile::FileMode::Truncate;
file.reset(new NativeFile(filePath));
}
FindFile will fail and we get mode equal Read | Truncate but it is invalid state. std::fstream::is_open returns false and therefore I can't read a file.
1 .Is it possible to fix? Perhaps something like this will be fine?
if (!isExists && !IsReadOnlyST()) {
if (mode & IFile::FileMode::Write) {
mode = mode | IFile::FileMode::Truncate;
}
file.reset(new NativeFile(filePath));
}
- Why do the lib add "Truncate" mode to a new file? What If I don't want to discard content..
I need to copy file from any location to the project folder (smth like Import action for resources/assets), that's why I use std::filesystem::copy/copy_file for this purpose. Then I've faced problems with the lib.
So, Filesystem fills m_FileList during initialization step. If I add a new file after this step and then try to OpenFile with mode Read it will fall into this piece of code:
IFilePtr file = FindFile(filePath, m_FileList); bool isExists = (file != nullptr); if (!isExists && !IsReadOnlyST()) { mode = mode | IFile::FileMode::Truncate; file.reset(new NativeFile(filePath)); }FindFile will fail and we get mode equal
Read | Truncatebut it is invalid state.std::fstream::is_openreturns false and therefore I can't read a file.1 .Is it possible to fix? Perhaps something like this will be fine?