Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2020-03-13 16:48:22 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-03-13 16:48:22 +0300
commit85ede2892bf8f650d18f0c44da0adc71023df626 (patch)
tree3502e193543545118cada81543c44aadd282d5f0 /src/Storage/MassStorage.cpp
parent53ac229acbc65277d9c98f8e9037664ab6bec11c (diff)
File operations invoked via http no longer generate error messages
Aso removed object mode field sensors.analog[].number
Diffstat (limited to 'src/Storage/MassStorage.cpp')
-rw-r--r--src/Storage/MassStorage.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/Storage/MassStorage.cpp b/src/Storage/MassStorage.cpp
index 47154753..3b969a05 100644
--- a/src/Storage/MassStorage.cpp
+++ b/src/Storage/MassStorage.cpp
@@ -376,7 +376,7 @@ const char* MassStorage::GetMonthName(const uint8_t month) noexcept
}
// Delete a file or directory
-bool MassStorage::Delete(const char* filePath) noexcept
+bool MassStorage::Delete(const char* filePath, bool messageIfFailed) noexcept
{
FRESULT unlinkReturn;
bool isOpen = false;
@@ -418,7 +418,10 @@ bool MassStorage::Delete(const char* filePath) noexcept
// If the error was that the file or path doesn't exist, don't generate a global error message, but still return false
if (unlinkReturn != FR_NO_FILE && unlinkReturn != FR_NO_PATH)
{
- reprap.GetPlatform().MessageF(ErrorMessage, "Failed to delete file %s\n", filePath);
+ if (messageIfFailed)
+ {
+ reprap.GetPlatform().MessageF(ErrorMessage, "Failed to delete file %s\n", filePath);
+ }
}
return false;
}
@@ -426,7 +429,7 @@ bool MassStorage::Delete(const char* filePath) noexcept
}
// Ensure that the path up to the last '/' (excluding trailing '/' characters) in filePath exists, returning true if successful
-bool MassStorage::EnsurePath(const char* filePath) noexcept
+bool MassStorage::EnsurePath(const char* filePath, bool messageIfFailed) noexcept
{
// Try to create the path of this file if we want to write to it
String<MaxFilenameLength> filePathCopy;
@@ -450,7 +453,10 @@ bool MassStorage::EnsurePath(const char* filePath) noexcept
filePathCopy[i] = 0;
if (!MassStorage::DirectoryExists(filePathCopy.GetRef()) && f_mkdir(filePathCopy.c_str()) != FR_OK)
{
- reprap.GetPlatform().MessageF(ErrorMessage, "Failed to create folder %s in path %s\n", filePathCopy.c_str(), filePath);
+ if (messageIfFailed)
+ {
+ reprap.GetPlatform().MessageF(ErrorMessage, "Failed to create folder %s in path %s\n", filePathCopy.c_str(), filePath);
+ }
return false;
}
filePathCopy[i] = '/';
@@ -461,22 +467,25 @@ bool MassStorage::EnsurePath(const char* filePath) noexcept
}
// Create a new directory
-bool MassStorage::MakeDirectory(const char *directory) noexcept
+bool MassStorage::MakeDirectory(const char *directory, bool messageIfFailed) noexcept
{
- if (!EnsurePath(directory))
+ if (!EnsurePath(directory, messageIfFailed))
{
return false;
}
if (f_mkdir(directory) != FR_OK)
{
- reprap.GetPlatform().MessageF(ErrorMessage, "Failed to create folder %s\n", directory);
+ if (messageIfFailed)
+ {
+ reprap.GetPlatform().MessageF(ErrorMessage, "Failed to create folder %s\n", directory);
+ }
return false;
}
return true;
}
// Rename a file or directory
-bool MassStorage::Rename(const char *oldFilename, const char *newFilename) noexcept
+bool MassStorage::Rename(const char *oldFilename, const char *newFilename, bool messageIfFailed) noexcept
{
if (newFilename[0] >= '0' && newFilename[0] <= '9' && newFilename[1] == ':')
{
@@ -485,13 +494,16 @@ bool MassStorage::Rename(const char *oldFilename, const char *newFilename) noexc
// We are assuming that the user isn't really trying to rename across volumes. This is a safe assumption when the client is DWC.
newFilename += 2;
}
- if (!EnsurePath(newFilename))
+ if (!EnsurePath(newFilename, messageIfFailed))
{
return false;
}
if (f_rename(oldFilename, newFilename) != FR_OK)
{
- reprap.GetPlatform().MessageF(ErrorMessage, "Failed to rename file or directory %s to %s\n", oldFilename, newFilename);
+ if (messageIfFailed)
+ {
+ reprap.GetPlatform().MessageF(ErrorMessage, "Failed to rename file or directory %s to %s\n", oldFilename, newFilename);
+ }
return false;
}
return true;