diff options
author | David Crocker <dcrocker@eschertech.com> | 2016-12-21 20:17:32 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2016-12-21 20:17:57 +0300 |
commit | fdcef50706f111394d3ca6a5edbcad4d70c89fd6 (patch) | |
tree | 22a4e7075cc736039ed1d328bbb3b0797e788b4a /src/Storage | |
parent | 8bfd6d49f61acb906558e8bf7557f5c16d089d2b (diff) |
Version 1.17RC3
Bed compensation taper is now applied to 3/4/5-point compensation
methods too
Recognise generated-with comment in new Cura gcode files
Recognise filament-used info min new kisslicer files
When uploading files, create the full path if necessary
Duet 0.8.5 webserver looks for gzipped files first
A second controlled fan on the Duet 0.6 is no longer inverted
Diffstat (limited to 'src/Storage')
-rw-r--r-- | src/Storage/FileStore.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Storage/FileStore.cpp b/src/Storage/FileStore.cpp index 680032f8..cc8207fd 100644 --- a/src/Storage/FileStore.cpp +++ b/src/Storage/FileStore.cpp @@ -47,6 +47,36 @@ bool FileStore::Open(const char* directory, const char* fileName, bool write) writing = write; lastBufferEntry = FileBufLen; + // Try to create the path of this file if we want to write to it + if (writing) + { + char filePathBuffer[FILENAME_LENGTH]; + StringRef filePath(filePathBuffer, FILENAME_LENGTH); + filePath.copy(location); + + bool isVolume = isdigit(filePath[0]); + for(size_t i = 1; i < filePath.strlen(); i++) + { + if (filePath[i] == '/') + { + if (isVolume) + { + isVolume = false; + continue; + } + + filePath[i] = 0; + if (!platform->GetMassStorage()->DirectoryExists(filePath.Pointer()) && !platform->GetMassStorage()->MakeDirectory(filePath.Pointer())) + { + platform->MessageF(GENERIC_MESSAGE, "Failed to create directory %s while trying to open file %s\n", + filePath.Pointer(), location); + return false; + } + filePath[i] = '/'; + } + } + } + FRESULT openReturn = f_open(&file, location, (writing) ? FA_CREATE_ALWAYS | FA_WRITE : FA_OPEN_EXISTING | FA_READ); if (openReturn != FR_OK) { |