summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-12-01 18:44:37 +0100
committerTannin <devnull@localhost>2014-12-01 18:44:37 +0100
commit226993eecee22e3cb39fc30aedfef587cc58330c (patch)
treef62b12ff4f2db4fce2eae1dddd6781562c7ad5b1 /src/shared
parent78da5fc37ff3a488dc0db8704f2c93cef48dbb57 (diff)
- added error handling when a file can't be deleted from vfs
- minor bugfixes
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/directoryentry.cpp12
-rw-r--r--src/shared/directoryentry.h10
2 files changed, 14 insertions, 8 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 0adf0812..7c0e7119 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -563,17 +563,19 @@ void DirectoryEntry::addFiles(FilesOrigin &origin, BSA::Folder::Ptr archiveFolde
}
-void DirectoryEntry::removeFile(const std::wstring &filePath, int *origin)
+bool DirectoryEntry::removeFile(const std::wstring &filePath, int *origin)
{
size_t pos = filePath.find_first_of(L"\\/");
if (pos == std::string::npos) {
- this->remove(filePath, origin);
+ return this->remove(filePath, origin);
} else {
std::wstring dirName = filePath.substr(0, pos);
std::wstring rest = filePath.substr(pos + 1);
DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false);
if (entry != NULL) {
- entry->removeFile(rest, origin);
+ return entry->removeFile(rest, origin);
+ } else {
+ return false;
}
}
}
@@ -894,14 +896,16 @@ void FileRegister::unregisterFile(FileEntry::Ptr file)
}
-void FileRegister::removeFile(FileEntry::Index index)
+bool FileRegister::removeFile(FileEntry::Index index)
{
auto iter = m_Files.find(index);
if (iter != m_Files.end()) {
unregisterFile(iter->second);
m_Files.erase(index);
+ return true;
} else {
log("invalid file index for remove: %lu", index);
+ return false;
}
}
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index d588ab02..c06a49a1 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -184,7 +184,7 @@ public:
size_t size() const { return m_Files.size(); }
- void removeFile(FileEntry::Index index);
+ bool removeFile(FileEntry::Index index);
void removeOrigin(FileEntry::Index index, int originID);
void removeOriginMulti(std::set<FileEntry::Index> indices, int originID, time_t notAfter);
@@ -263,7 +263,7 @@ public:
void removeFile(FileEntry::Index index);
// remove the specified file from the tree. This can be a path leading to a file in a subdirectory
- void removeFile(const std::wstring &filePath, int *origin = NULL);
+ bool removeFile(const std::wstring &filePath, int *origin = NULL);
/**
* @brief remove the specified directory
@@ -271,7 +271,7 @@ public:
*/
void removeDir(const std::wstring &path);
- void remove(const std::wstring &fileName, int *origin) {
+ bool remove(const std::wstring &fileName, int *origin) {
auto iter = m_Files.find(ToLower(fileName));
if (iter != m_Files.end()) {
if (origin != NULL) {
@@ -281,7 +281,9 @@ public:
*origin = entry->getOrigin(ignore);
}
}
- m_FileRegister->removeFile(iter->second);
+ return m_FileRegister->removeFile(iter->second);
+ } else {
+ return false;
}
}