mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Merge pull request #619 from davidgiven/b602
Fix weird error when trying to create fatfs filesystems.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "lib/bytes.h"
|
||||
#include <fmt/format.h>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
||||
bool emergencyStop = false;
|
||||
|
||||
@@ -190,3 +191,10 @@ std::string tohex(const std::string& s)
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool doesFileExist(const std::string& filename)
|
||||
{
|
||||
std::ifstream f(filename);
|
||||
return f.good();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ extern std::string toIso8601(time_t t);
|
||||
extern std::string quote(const std::string& s);
|
||||
extern std::string unhex(const std::string& s);
|
||||
extern std::string tohex(const std::string& s);
|
||||
extern bool doesFileExist(const std::string& filename);
|
||||
|
||||
/* If set, any running job will terminate as soon as possible (with an error).
|
||||
*/
|
||||
|
||||
@@ -246,11 +246,11 @@ public:
|
||||
switch (cmd)
|
||||
{
|
||||
case GET_SECTOR_SIZE:
|
||||
*(DWORD*)buffer = getLogicalSectorSize();
|
||||
*(WORD*)buffer = getLogicalSectorSize();
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD*)buffer = getLogicalSectorCount();
|
||||
*(LBA_t*)buffer = getLogicalSectorCount();
|
||||
break;
|
||||
|
||||
case CTRL_SYNC:
|
||||
|
||||
@@ -235,7 +235,8 @@ std::unique_ptr<Filesystem> Filesystem::createFilesystemFromConfig()
|
||||
{
|
||||
std::shared_ptr<ImageReader> reader;
|
||||
std::shared_ptr<ImageWriter> writer;
|
||||
if (config.image_reader().type() != ImageReaderProto::NOT_SET)
|
||||
if ((config.image_reader().type() != ImageReaderProto::NOT_SET) &&
|
||||
doesFileExist(config.image_reader().filename()))
|
||||
reader = ImageReader::create(config.image_reader());
|
||||
if (config.image_writer().type() != ImageWriterProto::NOT_SET)
|
||||
writer = ImageWriter::create(config.image_writer());
|
||||
|
||||
Reference in New Issue
Block a user