summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/directoryentry.cpp12
-rw-r--r--src/shared/error_report.cpp45
-rw-r--r--src/shared/error_report.h21
3 files changed, 8 insertions, 70 deletions
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index bde515a9..9d9edd85 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -103,7 +103,7 @@ public:
m_OriginsNameMap.erase(iter);
m_OriginsNameMap[newName] = idx;
} else {
- log("failed to change name lookup from %ls to %ls", oldName.c_str(), newName.c_str());
+ vlog("failed to change name lookup from %ls to %ls", oldName.c_str(), newName.c_str());
}
}
@@ -714,12 +714,12 @@ void DirectoryEntry::removeFile(FileEntry::Index index)
if (iter != m_Files.end()) {
m_Files.erase(iter);
} else {
- log("file \"%ls\" not in directory \"%ls\"",
+ vlog("file \"%ls\" not in directory \"%ls\"",
m_FileRegister->getFile(index)->getName().c_str(),
this->getName().c_str());
}
} else {
- log("file \"%ls\" not in directory \"%ls\", directory empty",
+ vlog("file \"%ls\" not in directory \"%ls\", directory empty",
m_FileRegister->getFile(index)->getName().c_str(),
this->getName().c_str());
}
@@ -844,7 +844,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const
DirectoryEntry *temp = findSubDirectory(pathComponent);
if (temp != nullptr) {
if (len >= path.size()) {
- log("unexpected end of path");
+ vlog("unexpected end of path");
return FileEntry::Ptr();
}
return temp->searchFile(path.substr(len + 1), directory);
@@ -988,7 +988,7 @@ bool FileRegister::removeFile(FileEntry::Index index)
m_Files.erase(index);
return true;
} else {
- log("invalid file index for remove: %lu", index);
+ vlog("invalid file index for remove: %lu", index);
return false;
}
}
@@ -1002,7 +1002,7 @@ void FileRegister::removeOrigin(FileEntry::Index index, int originID)
m_Files.erase(iter);
}
} else {
- log("invalid file index for remove (for origin): %lu", index);
+ vlog("invalid file index for remove (for origin): %lu", index);
}
}
diff --git a/src/shared/error_report.cpp b/src/shared/error_report.cpp
index 6d091630..4185b544 100644
--- a/src/shared/error_report.cpp
+++ b/src/shared/error_report.cpp
@@ -23,7 +23,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-
void reportError(LPCSTR format, ...)
{
char buffer[1025];
@@ -52,48 +51,4 @@ void reportError(LPCWSTR format, ...)
MessageBoxW(nullptr, buffer, L"Error", MB_OK | MB_ICONERROR);
}
-
-std::string getCurrentErrorStringA()
-{
- LPSTR buffer = nullptr;
-
- DWORD errorCode = ::GetLastError();
-
- if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
- ::SetLastError(errorCode);
- return std::string();
- } else {
- LPSTR lastChar = buffer + strlen(buffer) - 2;
- *lastChar = '\0';
-
- std::string result(buffer);
-
- LocalFree(buffer);
- ::SetLastError(errorCode);
- return result;
- }
-}
-
-std::wstring getCurrentErrorStringW()
-{
- LPWSTR buffer = nullptr;
-
- DWORD errorCode = ::GetLastError();
-
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&buffer, 0, nullptr) == 0) {
- ::SetLastError(errorCode);
- return std::wstring();
- } else {
- LPWSTR lastChar = buffer + wcslen(buffer) - 2;
- *lastChar = '\0';
-
- std::wstring result(buffer);
-
- LocalFree(buffer);
- ::SetLastError(errorCode);
- return result;
- }
-}
} // namespace MOShared
diff --git a/src/shared/error_report.h b/src/shared/error_report.h
index c09ad75b..a003ee09 100644
--- a/src/shared/error_report.h
+++ b/src/shared/error_report.h
@@ -24,28 +24,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <Windows.h>
#include <string>
-namespace std {
-#ifdef UNICODE
-typedef wstring tstring;
-#else
-typedef string tstring;
-#endif
-}
-
-extern void log(const char* format, ...);
-
namespace MOShared {
void reportError(LPCSTR format, ...);
void reportError(LPCWSTR format, ...);
-std::string getCurrentErrorStringA();
-std::wstring getCurrentErrorStringW();
-
-#ifdef UNICODE
-#define getCurrentErrorString getCurrentErrorStringW
-#else
-#define getCurrentErrorString getCurrentErrorStringA
-#endif
-
} // namespace MOShared
+
+void vlog(const char* format, ...);