mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Common/CommonFuncs: Move interface into Common namespace
Gets these functions out of the global namespace.
This commit is contained in:
@ -13,6 +13,8 @@
|
||||
#define strerror_r(err, buf, len) strerror_s(buf, len, err)
|
||||
#endif
|
||||
|
||||
namespace Common
|
||||
{
|
||||
constexpr size_t BUFFER_SIZE = 256;
|
||||
|
||||
// Wrapper function to get last strerror(errno) string.
|
||||
@ -73,3 +75,4 @@ std::optional<std::wstring> GetModuleName(void* hInstance)
|
||||
return name;
|
||||
}
|
||||
#endif
|
||||
} // namespace Common
|
||||
|
@ -39,6 +39,8 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
|
||||
}
|
||||
#endif // WIN32 ndef
|
||||
|
||||
namespace Common
|
||||
{
|
||||
// Wrapper function to get last strerror(errno) string.
|
||||
// This function might change the error code.
|
||||
std::string LastStrerrorString();
|
||||
@ -51,3 +53,4 @@ std::string GetLastErrorString();
|
||||
// Obtains a full path to the specified module.
|
||||
std::optional<std::wstring> GetModuleName(void* hInstance);
|
||||
#endif
|
||||
} // namespace Common
|
||||
|
@ -170,7 +170,7 @@ static std::optional<std::wstring> GetModulePath(const wchar_t* name)
|
||||
if (module == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
return GetModuleName(module);
|
||||
return Common::GetModuleName(module);
|
||||
}
|
||||
|
||||
static bool GetModuleVersion(const wchar_t* name, Version* version)
|
||||
|
@ -358,14 +358,14 @@ u64 GetSize(FILE* f)
|
||||
const u64 pos = ftello(f);
|
||||
if (fseeko(f, 0, SEEK_END) != 0)
|
||||
{
|
||||
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
|
||||
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), Common::LastStrerrorString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
const u64 size = ftello(f);
|
||||
if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0))
|
||||
{
|
||||
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), LastStrerrorString());
|
||||
ERROR_LOG_FMT(COMMON, "GetSize: seek failed {}: {}", fmt::ptr(f), Common::LastStrerrorString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -379,7 +379,7 @@ bool CreateEmptyFile(const std::string& filename)
|
||||
|
||||
if (!File::IOFile(filename, "wb"))
|
||||
{
|
||||
ERROR_LOG_FMT(COMMON, "CreateEmptyFile: failed {}: {}", filename, LastStrerrorString());
|
||||
ERROR_LOG_FMT(COMMON, "CreateEmptyFile: failed {}: {}", filename, Common::LastStrerrorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -726,7 +726,7 @@ std::string GetBundleDirectory()
|
||||
std::string GetExePath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
auto exe_path = GetModuleName(nullptr);
|
||||
auto exe_path = Common::GetModuleName(nullptr);
|
||||
if (!exe_path)
|
||||
return {};
|
||||
std::error_code error;
|
||||
|
Reference in New Issue
Block a user