windows compiles, some unittests give exceptions
This commit is contained in:
@ -5,11 +5,15 @@
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
ReturnValue_t FilesystemMock::feedFile(const std::string &filename, std::ifstream &file) {
|
||||
if (not std::filesystem::exists(filename)) {
|
||||
|
||||
//not multibyte encoding safe!
|
||||
std::basic_string<std::filesystem::path::value_type> native_filename(filename.begin(), filename.end());
|
||||
|
||||
if (not std::filesystem::exists(native_filename)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
size_t fileSize = std::filesystem::file_size(filename);
|
||||
FileOpParams params(filename.c_str(), fileSize);
|
||||
size_t fileSize = std::filesystem::file_size(native_filename);
|
||||
FileOpParams params(native_filename.c_str(), fileSize);
|
||||
std::vector<uint8_t> rawData(fileSize);
|
||||
file.read(reinterpret_cast<char *>(rawData.data()), static_cast<unsigned int>(rawData.size()));
|
||||
createOrAddToFile(params, rawData.data());
|
||||
@ -23,7 +27,7 @@ ReturnValue_t FilesystemMock::writeToFile(FileOpParams params, const uint8_t *da
|
||||
|
||||
ReturnValue_t FilesystemMock::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize,
|
||||
size_t maxSize) {
|
||||
std::string filename(params.path());
|
||||
std::basic_string<std::filesystem::path::value_type> filename(params.path());
|
||||
auto iter = fileMap.find(filename);
|
||||
if (iter == fileMap.end()) {
|
||||
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
||||
@ -53,8 +57,10 @@ ReturnValue_t FilesystemMock::createFile(FilesystemParams params, const uint8_t
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *args) {
|
||||
std::string filename(path);
|
||||
ReturnValue_t FilesystemMock::removeFile(const std::filesystem::path::value_type *path,
|
||||
FileSystemArgsIF *args) {
|
||||
std::basic_string<std::filesystem::path::value_type> filename(path);
|
||||
|
||||
auto iter = fileMap.find(filename);
|
||||
if (iter == fileMap.end()) {
|
||||
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
||||
@ -65,27 +71,28 @@ ReturnValue_t FilesystemMock::removeFile(const char *path, FileSystemArgsIF *arg
|
||||
}
|
||||
|
||||
ReturnValue_t FilesystemMock::createDirectory(FilesystemParams params, bool createParentDirs) {
|
||||
std::string dirPath = params.path;
|
||||
auto dirPath = params.path;
|
||||
dirMap[dirPath].createCallCount++;
|
||||
dirMap[dirPath].wihParentDir.push(createParentDirs);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FilesystemMock::removeDirectory(FilesystemParams params, bool deleteRecurively) {
|
||||
std::string dirPath = params.path;
|
||||
auto dirPath = params.path;
|
||||
dirMap[dirPath].delCallCount++;
|
||||
dirMap[dirPath].recursiveDeletion.push(deleteRecurively);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t FilesystemMock::rename(const char *oldPath, const char *newPath,
|
||||
ReturnValue_t FilesystemMock::rename(const std::filesystem::path::value_type *oldPath,
|
||||
const std::filesystem::path::value_type *newPath,
|
||||
FileSystemArgsIF *args) {
|
||||
renameQueue.push(RenameInfo(oldPath, newPath));
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void FilesystemMock::createOrAddToFile(FileOpParams params, const uint8_t *data) {
|
||||
std::string filename(params.path());
|
||||
auto filename(params.path());
|
||||
auto iter = fileMap.find(filename);
|
||||
if (iter == fileMap.end()) {
|
||||
FileSegmentQueue queue;
|
||||
@ -126,7 +133,7 @@ void FilesystemMock::reset() {
|
||||
}
|
||||
|
||||
bool FilesystemMock::fileExists(FilesystemParams params) {
|
||||
std::string filename(params.path);
|
||||
auto filename(params.path);
|
||||
auto iter = fileMap.find(filename);
|
||||
if (iter == fileMap.end()) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user