diff options
| author | 2018-04-26 22:53:14 -0400 | |
|---|---|---|
| committer | 2018-04-26 22:53:14 -0400 | |
| commit | 18f8012233cda88aacf01c59f89abf3a687ab2c9 (patch) | |
| tree | f1b13d10c366085c1a85e80aeb48dfb6776e01a7 /src | |
| parent | Merge pull request #405 from lioncash/input (diff) | |
| parent | common: Move logging macros over to new fmt-capable macros where applicable (diff) | |
| download | yuzu-18f8012233cda88aacf01c59f89abf3a687ab2c9.tar.gz yuzu-18f8012233cda88aacf01c59f89abf3a687ab2c9.tar.xz yuzu-18f8012233cda88aacf01c59f89abf3a687ab2c9.zip | |
Merge pull request #407 from lioncash/common
common: Move logging macros over to new fmt-capable macros where applicable
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/file_util.cpp | 96 | ||||
| -rw-r--r-- | src/common/memory_util.cpp | 16 | ||||
| -rw-r--r-- | src/common/param_package.cpp | 12 | ||||
| -rw-r--r-- | src/common/string_util.cpp | 10 |
4 files changed, 67 insertions, 67 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 4e1d702f7..37f9e996c 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -118,7 +118,7 @@ bool IsDirectory(const std::string& filename) { | |||
| 118 | #endif | 118 | #endif |
| 119 | 119 | ||
| 120 | if (result < 0) { | 120 | if (result < 0) { |
| 121 | LOG_DEBUG(Common_Filesystem, "stat failed on %s: %s", filename.c_str(), GetLastErrorMsg()); | 121 | NGLOG_DEBUG(Common_Filesystem, "stat failed on {}: {}", filename, GetLastErrorMsg()); |
| 122 | return false; | 122 | return false; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| @@ -128,31 +128,29 @@ bool IsDirectory(const std::string& filename) { | |||
| 128 | // Deletes a given filename, return true on success | 128 | // Deletes a given filename, return true on success |
| 129 | // Doesn't supports deleting a directory | 129 | // Doesn't supports deleting a directory |
| 130 | bool Delete(const std::string& filename) { | 130 | bool Delete(const std::string& filename) { |
| 131 | LOG_TRACE(Common_Filesystem, "file %s", filename.c_str()); | 131 | NGLOG_TRACE(Common_Filesystem, "file {}", filename); |
| 132 | 132 | ||
| 133 | // Return true because we care about the file no | 133 | // Return true because we care about the file no |
| 134 | // being there, not the actual delete. | 134 | // being there, not the actual delete. |
| 135 | if (!Exists(filename)) { | 135 | if (!Exists(filename)) { |
| 136 | LOG_DEBUG(Common_Filesystem, "%s does not exist", filename.c_str()); | 136 | NGLOG_DEBUG(Common_Filesystem, "{} does not exist", filename); |
| 137 | return true; | 137 | return true; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | // We can't delete a directory | 140 | // We can't delete a directory |
| 141 | if (IsDirectory(filename)) { | 141 | if (IsDirectory(filename)) { |
| 142 | LOG_ERROR(Common_Filesystem, "Failed: %s is a directory", filename.c_str()); | 142 | NGLOG_ERROR(Common_Filesystem, "Failed: {} is a directory", filename); |
| 143 | return false; | 143 | return false; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | #ifdef _WIN32 | 146 | #ifdef _WIN32 |
| 147 | if (!DeleteFileW(Common::UTF8ToUTF16W(filename).c_str())) { | 147 | if (!DeleteFileW(Common::UTF8ToUTF16W(filename).c_str())) { |
| 148 | LOG_ERROR(Common_Filesystem, "DeleteFile failed on %s: %s", filename.c_str(), | 148 | NGLOG_ERROR(Common_Filesystem, "DeleteFile failed on {}: {}", filename, GetLastErrorMsg()); |
| 149 | GetLastErrorMsg()); | ||
| 150 | return false; | 149 | return false; |
| 151 | } | 150 | } |
| 152 | #else | 151 | #else |
| 153 | if (unlink(filename.c_str()) == -1) { | 152 | if (unlink(filename.c_str()) == -1) { |
| 154 | LOG_ERROR(Common_Filesystem, "unlink failed on %s: %s", filename.c_str(), | 153 | NGLOG_ERROR(Common_Filesystem, "unlink failed on {}: {}", filename, GetLastErrorMsg()); |
| 155 | GetLastErrorMsg()); | ||
| 156 | return false; | 154 | return false; |
| 157 | } | 155 | } |
| 158 | #endif | 156 | #endif |
| @@ -162,16 +160,16 @@ bool Delete(const std::string& filename) { | |||
| 162 | 160 | ||
| 163 | // Returns true if successful, or path already exists. | 161 | // Returns true if successful, or path already exists. |
| 164 | bool CreateDir(const std::string& path) { | 162 | bool CreateDir(const std::string& path) { |
| 165 | LOG_TRACE(Common_Filesystem, "directory %s", path.c_str()); | 163 | NGLOG_TRACE(Common_Filesystem, "directory {}", path); |
| 166 | #ifdef _WIN32 | 164 | #ifdef _WIN32 |
| 167 | if (::CreateDirectoryW(Common::UTF8ToUTF16W(path).c_str(), nullptr)) | 165 | if (::CreateDirectoryW(Common::UTF8ToUTF16W(path).c_str(), nullptr)) |
| 168 | return true; | 166 | return true; |
| 169 | DWORD error = GetLastError(); | 167 | DWORD error = GetLastError(); |
| 170 | if (error == ERROR_ALREADY_EXISTS) { | 168 | if (error == ERROR_ALREADY_EXISTS) { |
| 171 | LOG_DEBUG(Common_Filesystem, "CreateDirectory failed on %s: already exists", path.c_str()); | 169 | NGLOG_DEBUG(Common_Filesystem, "CreateDirectory failed on {}: already exists", path); |
| 172 | return true; | 170 | return true; |
| 173 | } | 171 | } |
| 174 | LOG_ERROR(Common_Filesystem, "CreateDirectory failed on %s: %i", path.c_str(), error); | 172 | NGLOG_ERROR(Common_Filesystem, "CreateDirectory failed on {}: {}", path, error); |
| 175 | return false; | 173 | return false; |
| 176 | #else | 174 | #else |
| 177 | if (mkdir(path.c_str(), 0755) == 0) | 175 | if (mkdir(path.c_str(), 0755) == 0) |
| @@ -180,11 +178,11 @@ bool CreateDir(const std::string& path) { | |||
| 180 | int err = errno; | 178 | int err = errno; |
| 181 | 179 | ||
| 182 | if (err == EEXIST) { | 180 | if (err == EEXIST) { |
| 183 | LOG_DEBUG(Common_Filesystem, "mkdir failed on %s: already exists", path.c_str()); | 181 | NGLOG_DEBUG(Common_Filesystem, "mkdir failed on {}: already exists", path); |
| 184 | return true; | 182 | return true; |
| 185 | } | 183 | } |
| 186 | 184 | ||
| 187 | LOG_ERROR(Common_Filesystem, "mkdir failed on %s: %s", path.c_str(), strerror(err)); | 185 | NGLOG_ERROR(Common_Filesystem, "mkdir failed on {}: {}", path, strerror(err)); |
| 188 | return false; | 186 | return false; |
| 189 | #endif | 187 | #endif |
| 190 | } | 188 | } |
| @@ -192,10 +190,10 @@ bool CreateDir(const std::string& path) { | |||
| 192 | // Creates the full path of fullPath returns true on success | 190 | // Creates the full path of fullPath returns true on success |
| 193 | bool CreateFullPath(const std::string& fullPath) { | 191 | bool CreateFullPath(const std::string& fullPath) { |
| 194 | int panicCounter = 100; | 192 | int panicCounter = 100; |
| 195 | LOG_TRACE(Common_Filesystem, "path %s", fullPath.c_str()); | 193 | NGLOG_TRACE(Common_Filesystem, "path {}", fullPath); |
| 196 | 194 | ||
| 197 | if (FileUtil::Exists(fullPath)) { | 195 | if (FileUtil::Exists(fullPath)) { |
| 198 | LOG_DEBUG(Common_Filesystem, "path exists %s", fullPath.c_str()); | 196 | NGLOG_DEBUG(Common_Filesystem, "path exists {}", fullPath); |
| 199 | return true; | 197 | return true; |
| 200 | } | 198 | } |
| 201 | 199 | ||
| @@ -211,14 +209,14 @@ bool CreateFullPath(const std::string& fullPath) { | |||
| 211 | // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") | 209 | // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") |
| 212 | std::string const subPath(fullPath.substr(0, position + 1)); | 210 | std::string const subPath(fullPath.substr(0, position + 1)); |
| 213 | if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { | 211 | if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { |
| 214 | LOG_ERROR(Common, "CreateFullPath: directory creation failed"); | 212 | NGLOG_ERROR(Common, "CreateFullPath: directory creation failed"); |
| 215 | return false; | 213 | return false; |
| 216 | } | 214 | } |
| 217 | 215 | ||
| 218 | // A safety check | 216 | // A safety check |
| 219 | panicCounter--; | 217 | panicCounter--; |
| 220 | if (panicCounter <= 0) { | 218 | if (panicCounter <= 0) { |
| 221 | LOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); | 219 | NGLOG_ERROR(Common, "CreateFullPath: directory structure is too deep"); |
| 222 | return false; | 220 | return false; |
| 223 | } | 221 | } |
| 224 | position++; | 222 | position++; |
| @@ -227,11 +225,11 @@ bool CreateFullPath(const std::string& fullPath) { | |||
| 227 | 225 | ||
| 228 | // Deletes a directory filename, returns true on success | 226 | // Deletes a directory filename, returns true on success |
| 229 | bool DeleteDir(const std::string& filename) { | 227 | bool DeleteDir(const std::string& filename) { |
| 230 | LOG_TRACE(Common_Filesystem, "directory %s", filename.c_str()); | 228 | NGLOG_TRACE(Common_Filesystem, "directory {}", filename); |
| 231 | 229 | ||
| 232 | // check if a directory | 230 | // check if a directory |
| 233 | if (!FileUtil::IsDirectory(filename)) { | 231 | if (!FileUtil::IsDirectory(filename)) { |
| 234 | LOG_ERROR(Common_Filesystem, "Not a directory %s", filename.c_str()); | 232 | NGLOG_ERROR(Common_Filesystem, "Not a directory {}", filename); |
| 235 | return false; | 233 | return false; |
| 236 | } | 234 | } |
| 237 | 235 | ||
| @@ -242,14 +240,14 @@ bool DeleteDir(const std::string& filename) { | |||
| 242 | if (rmdir(filename.c_str()) == 0) | 240 | if (rmdir(filename.c_str()) == 0) |
| 243 | return true; | 241 | return true; |
| 244 | #endif | 242 | #endif |
| 245 | LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg()); | 243 | NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); |
| 246 | 244 | ||
| 247 | return false; | 245 | return false; |
| 248 | } | 246 | } |
| 249 | 247 | ||
| 250 | // renames file srcFilename to destFilename, returns true on success | 248 | // renames file srcFilename to destFilename, returns true on success |
| 251 | bool Rename(const std::string& srcFilename, const std::string& destFilename) { | 249 | bool Rename(const std::string& srcFilename, const std::string& destFilename) { |
| 252 | LOG_TRACE(Common_Filesystem, "%s --> %s", srcFilename.c_str(), destFilename.c_str()); | 250 | NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); |
| 253 | #ifdef _WIN32 | 251 | #ifdef _WIN32 |
| 254 | if (_wrename(Common::UTF8ToUTF16W(srcFilename).c_str(), | 252 | if (_wrename(Common::UTF8ToUTF16W(srcFilename).c_str(), |
| 255 | Common::UTF8ToUTF16W(destFilename).c_str()) == 0) | 253 | Common::UTF8ToUTF16W(destFilename).c_str()) == 0) |
| @@ -258,21 +256,21 @@ bool Rename(const std::string& srcFilename, const std::string& destFilename) { | |||
| 258 | if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) | 256 | if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) |
| 259 | return true; | 257 | return true; |
| 260 | #endif | 258 | #endif |
| 261 | LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), | 259 | NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, |
| 262 | GetLastErrorMsg()); | 260 | GetLastErrorMsg()); |
| 263 | return false; | 261 | return false; |
| 264 | } | 262 | } |
| 265 | 263 | ||
| 266 | // copies file srcFilename to destFilename, returns true on success | 264 | // copies file srcFilename to destFilename, returns true on success |
| 267 | bool Copy(const std::string& srcFilename, const std::string& destFilename) { | 265 | bool Copy(const std::string& srcFilename, const std::string& destFilename) { |
| 268 | LOG_TRACE(Common_Filesystem, "%s --> %s", srcFilename.c_str(), destFilename.c_str()); | 266 | NGLOG_TRACE(Common_Filesystem, "{} --> {}", srcFilename, destFilename); |
| 269 | #ifdef _WIN32 | 267 | #ifdef _WIN32 |
| 270 | if (CopyFileW(Common::UTF8ToUTF16W(srcFilename).c_str(), | 268 | if (CopyFileW(Common::UTF8ToUTF16W(srcFilename).c_str(), |
| 271 | Common::UTF8ToUTF16W(destFilename).c_str(), FALSE)) | 269 | Common::UTF8ToUTF16W(destFilename).c_str(), FALSE)) |
| 272 | return true; | 270 | return true; |
| 273 | 271 | ||
| 274 | LOG_ERROR(Common_Filesystem, "failed %s --> %s: %s", srcFilename.c_str(), destFilename.c_str(), | 272 | NGLOG_ERROR(Common_Filesystem, "failed {} --> {}: {}", srcFilename, destFilename, |
| 275 | GetLastErrorMsg()); | 273 | GetLastErrorMsg()); |
| 276 | return false; | 274 | return false; |
| 277 | #else | 275 | #else |
| 278 | 276 | ||
| @@ -284,8 +282,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { | |||
| 284 | // Open input file | 282 | // Open input file |
| 285 | FILE* input = fopen(srcFilename.c_str(), "rb"); | 283 | FILE* input = fopen(srcFilename.c_str(), "rb"); |
| 286 | if (!input) { | 284 | if (!input) { |
| 287 | LOG_ERROR(Common_Filesystem, "opening input failed %s --> %s: %s", srcFilename.c_str(), | 285 | NGLOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, |
| 288 | destFilename.c_str(), GetLastErrorMsg()); | 286 | destFilename, GetLastErrorMsg()); |
| 289 | return false; | 287 | return false; |
| 290 | } | 288 | } |
| 291 | 289 | ||
| @@ -293,8 +291,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { | |||
| 293 | FILE* output = fopen(destFilename.c_str(), "wb"); | 291 | FILE* output = fopen(destFilename.c_str(), "wb"); |
| 294 | if (!output) { | 292 | if (!output) { |
| 295 | fclose(input); | 293 | fclose(input); |
| 296 | LOG_ERROR(Common_Filesystem, "opening output failed %s --> %s: %s", srcFilename.c_str(), | 294 | NGLOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, |
| 297 | destFilename.c_str(), GetLastErrorMsg()); | 295 | destFilename, GetLastErrorMsg()); |
| 298 | return false; | 296 | return false; |
| 299 | } | 297 | } |
| 300 | 298 | ||
| @@ -304,8 +302,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { | |||
| 304 | size_t rnum = fread(buffer, sizeof(char), BSIZE, input); | 302 | size_t rnum = fread(buffer, sizeof(char), BSIZE, input); |
| 305 | if (rnum != BSIZE) { | 303 | if (rnum != BSIZE) { |
| 306 | if (ferror(input) != 0) { | 304 | if (ferror(input) != 0) { |
| 307 | LOG_ERROR(Common_Filesystem, "failed reading from source, %s --> %s: %s", | 305 | NGLOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", |
| 308 | srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); | 306 | srcFilename, destFilename, GetLastErrorMsg()); |
| 309 | goto bail; | 307 | goto bail; |
| 310 | } | 308 | } |
| 311 | } | 309 | } |
| @@ -313,8 +311,8 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { | |||
| 313 | // write output | 311 | // write output |
| 314 | size_t wnum = fwrite(buffer, sizeof(char), rnum, output); | 312 | size_t wnum = fwrite(buffer, sizeof(char), rnum, output); |
| 315 | if (wnum != rnum) { | 313 | if (wnum != rnum) { |
| 316 | LOG_ERROR(Common_Filesystem, "failed writing to output, %s --> %s: %s", | 314 | NGLOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, |
| 317 | srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); | 315 | destFilename, GetLastErrorMsg()); |
| 318 | goto bail; | 316 | goto bail; |
| 319 | } | 317 | } |
| 320 | } | 318 | } |
| @@ -334,12 +332,12 @@ bail: | |||
| 334 | // Returns the size of filename (64bit) | 332 | // Returns the size of filename (64bit) |
| 335 | u64 GetSize(const std::string& filename) { | 333 | u64 GetSize(const std::string& filename) { |
| 336 | if (!Exists(filename)) { | 334 | if (!Exists(filename)) { |
| 337 | LOG_ERROR(Common_Filesystem, "failed %s: No such file", filename.c_str()); | 335 | NGLOG_ERROR(Common_Filesystem, "failed {}: No such file", filename); |
| 338 | return 0; | 336 | return 0; |
| 339 | } | 337 | } |
| 340 | 338 | ||
| 341 | if (IsDirectory(filename)) { | 339 | if (IsDirectory(filename)) { |
| 342 | LOG_ERROR(Common_Filesystem, "failed %s: is a directory", filename.c_str()); | 340 | NGLOG_ERROR(Common_Filesystem, "failed {}: is a directory", filename); |
| 343 | return 0; | 341 | return 0; |
| 344 | } | 342 | } |
| 345 | 343 | ||
| @@ -350,11 +348,11 @@ u64 GetSize(const std::string& filename) { | |||
| 350 | if (stat(filename.c_str(), &buf) == 0) | 348 | if (stat(filename.c_str(), &buf) == 0) |
| 351 | #endif | 349 | #endif |
| 352 | { | 350 | { |
| 353 | LOG_TRACE(Common_Filesystem, "%s: %lld", filename.c_str(), (long long)buf.st_size); | 351 | NGLOG_TRACE(Common_Filesystem, "{}: {}", filename, buf.st_size); |
| 354 | return buf.st_size; | 352 | return buf.st_size; |
| 355 | } | 353 | } |
| 356 | 354 | ||
| 357 | LOG_ERROR(Common_Filesystem, "Stat failed %s: %s", filename.c_str(), GetLastErrorMsg()); | 355 | NGLOG_ERROR(Common_Filesystem, "Stat failed {}: {}", filename, GetLastErrorMsg()); |
| 358 | return 0; | 356 | return 0; |
| 359 | } | 357 | } |
| 360 | 358 | ||
| @@ -362,7 +360,7 @@ u64 GetSize(const std::string& filename) { | |||
| 362 | u64 GetSize(const int fd) { | 360 | u64 GetSize(const int fd) { |
| 363 | struct stat buf; | 361 | struct stat buf; |
| 364 | if (fstat(fd, &buf) != 0) { | 362 | if (fstat(fd, &buf) != 0) { |
| 365 | LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s", fd, GetLastErrorMsg()); | 363 | NGLOG_ERROR(Common_Filesystem, "GetSize: stat failed {}: {}", fd, GetLastErrorMsg()); |
| 366 | return 0; | 364 | return 0; |
| 367 | } | 365 | } |
| 368 | return buf.st_size; | 366 | return buf.st_size; |
| @@ -373,12 +371,14 @@ u64 GetSize(FILE* f) { | |||
| 373 | // can't use off_t here because it can be 32-bit | 371 | // can't use off_t here because it can be 32-bit |
| 374 | u64 pos = ftello(f); | 372 | u64 pos = ftello(f); |
| 375 | if (fseeko(f, 0, SEEK_END) != 0) { | 373 | if (fseeko(f, 0, SEEK_END) != 0) { |
| 376 | LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s", f, GetLastErrorMsg()); | 374 | NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), |
| 375 | GetLastErrorMsg()); | ||
| 377 | return 0; | 376 | return 0; |
| 378 | } | 377 | } |
| 379 | u64 size = ftello(f); | 378 | u64 size = ftello(f); |
| 380 | if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { | 379 | if ((size != pos) && (fseeko(f, pos, SEEK_SET) != 0)) { |
| 381 | LOG_ERROR(Common_Filesystem, "GetSize: seek failed %p: %s", f, GetLastErrorMsg()); | 380 | NGLOG_ERROR(Common_Filesystem, "GetSize: seek failed {}: {}", fmt::ptr(f), |
| 381 | GetLastErrorMsg()); | ||
| 382 | return 0; | 382 | return 0; |
| 383 | } | 383 | } |
| 384 | return size; | 384 | return size; |
| @@ -386,10 +386,10 @@ u64 GetSize(FILE* f) { | |||
| 386 | 386 | ||
| 387 | // creates an empty file filename, returns true on success | 387 | // creates an empty file filename, returns true on success |
| 388 | bool CreateEmptyFile(const std::string& filename) { | 388 | bool CreateEmptyFile(const std::string& filename) { |
| 389 | LOG_TRACE(Common_Filesystem, "%s", filename.c_str()); | 389 | NGLOG_TRACE(Common_Filesystem, "{}", filename); |
| 390 | 390 | ||
| 391 | if (!FileUtil::IOFile(filename, "wb")) { | 391 | if (!FileUtil::IOFile(filename, "wb")) { |
| 392 | LOG_ERROR(Common_Filesystem, "failed %s: %s", filename.c_str(), GetLastErrorMsg()); | 392 | NGLOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); |
| 393 | return false; | 393 | return false; |
| 394 | } | 394 | } |
| 395 | 395 | ||
| @@ -398,7 +398,7 @@ bool CreateEmptyFile(const std::string& filename) { | |||
| 398 | 398 | ||
| 399 | bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, | 399 | bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string& directory, |
| 400 | DirectoryEntryCallable callback) { | 400 | DirectoryEntryCallable callback) { |
| 401 | LOG_TRACE(Common_Filesystem, "directory %s", directory.c_str()); | 401 | NGLOG_TRACE(Common_Filesystem, "directory {}", directory); |
| 402 | 402 | ||
| 403 | // How many files + directories we found | 403 | // How many files + directories we found |
| 404 | unsigned found_entries = 0; | 404 | unsigned found_entries = 0; |
| @@ -556,7 +556,7 @@ std::string GetCurrentDir() { | |||
| 556 | char* dir; | 556 | char* dir; |
| 557 | if (!(dir = getcwd(nullptr, 0))) { | 557 | if (!(dir = getcwd(nullptr, 0))) { |
| 558 | #endif | 558 | #endif |
| 559 | LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s", GetLastErrorMsg()); | 559 | NGLOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); |
| 560 | return nullptr; | 560 | return nullptr; |
| 561 | } | 561 | } |
| 562 | #ifdef _WIN32 | 562 | #ifdef _WIN32 |
| @@ -676,7 +676,7 @@ std::string GetSysDirectory() { | |||
| 676 | #endif | 676 | #endif |
| 677 | sysDir += DIR_SEP; | 677 | sysDir += DIR_SEP; |
| 678 | 678 | ||
| 679 | LOG_DEBUG(Common_Filesystem, "Setting to %s:", sysDir.c_str()); | 679 | NGLOG_DEBUG(Common_Filesystem, "Setting to {}:", sysDir); |
| 680 | return sysDir; | 680 | return sysDir; |
| 681 | } | 681 | } |
| 682 | 682 | ||
| @@ -692,7 +692,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new | |||
| 692 | if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { | 692 | if (!FileUtil::IsDirectory(paths[D_USER_IDX])) { |
| 693 | paths[D_USER_IDX] = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP; | 693 | paths[D_USER_IDX] = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP; |
| 694 | } else { | 694 | } else { |
| 695 | LOG_INFO(Common_Filesystem, "Using the local user directory"); | 695 | NGLOG_INFO(Common_Filesystem, "Using the local user directory"); |
| 696 | } | 696 | } |
| 697 | 697 | ||
| 698 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; | 698 | paths[D_CONFIG_IDX] = paths[D_USER_IDX] + CONFIG_DIR DIR_SEP; |
| @@ -719,7 +719,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string& new | |||
| 719 | 719 | ||
| 720 | if (!newPath.empty()) { | 720 | if (!newPath.empty()) { |
| 721 | if (!FileUtil::IsDirectory(newPath)) { | 721 | if (!FileUtil::IsDirectory(newPath)) { |
| 722 | LOG_ERROR(Common_Filesystem, "Invalid path specified %s", newPath.c_str()); | 722 | NGLOG_ERROR(Common_Filesystem, "Invalid path specified {}", newPath); |
| 723 | return paths[DirIDX]; | 723 | return paths[DirIDX]; |
| 724 | } else { | 724 | } else { |
| 725 | paths[DirIDX] = newPath; | 725 | paths[DirIDX] = newPath; |
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 759ad02ca..79b7215d3 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp | |||
| @@ -55,7 +55,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { | |||
| 55 | if (ptr == MAP_FAILED) { | 55 | if (ptr == MAP_FAILED) { |
| 56 | ptr = nullptr; | 56 | ptr = nullptr; |
| 57 | #endif | 57 | #endif |
| 58 | LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); | 58 | NGLOG_ERROR(Common_Memory, "Failed to allocate executable memory"); |
| 59 | } | 59 | } |
| 60 | #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) | 60 | #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) |
| 61 | else { | 61 | else { |
| @@ -68,7 +68,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { | |||
| 68 | 68 | ||
| 69 | #if EMU_ARCH_BITS == 64 | 69 | #if EMU_ARCH_BITS == 64 |
| 70 | if ((u64)ptr >= 0x80000000 && low == true) | 70 | if ((u64)ptr >= 0x80000000 && low == true) |
| 71 | LOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); | 71 | NGLOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| 74 | return ptr; | 74 | return ptr; |
| @@ -85,7 +85,7 @@ void* AllocateMemoryPages(size_t size) { | |||
| 85 | #endif | 85 | #endif |
| 86 | 86 | ||
| 87 | if (ptr == nullptr) | 87 | if (ptr == nullptr) |
| 88 | LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); | 88 | NGLOG_ERROR(Common_Memory, "Failed to allocate raw memory"); |
| 89 | 89 | ||
| 90 | return ptr; | 90 | return ptr; |
| 91 | } | 91 | } |
| @@ -99,12 +99,12 @@ void* AllocateAlignedMemory(size_t size, size_t alignment) { | |||
| 99 | ptr = memalign(alignment, size); | 99 | ptr = memalign(alignment, size); |
| 100 | #else | 100 | #else |
| 101 | if (posix_memalign(&ptr, alignment, size) != 0) | 101 | if (posix_memalign(&ptr, alignment, size) != 0) |
| 102 | LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); | 102 | NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); |
| 103 | #endif | 103 | #endif |
| 104 | #endif | 104 | #endif |
| 105 | 105 | ||
| 106 | if (ptr == nullptr) | 106 | if (ptr == nullptr) |
| 107 | LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); | 107 | NGLOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); |
| 108 | 108 | ||
| 109 | return ptr; | 109 | return ptr; |
| 110 | } | 110 | } |
| @@ -113,7 +113,7 @@ void FreeMemoryPages(void* ptr, size_t size) { | |||
| 113 | if (ptr) { | 113 | if (ptr) { |
| 114 | #ifdef _WIN32 | 114 | #ifdef _WIN32 |
| 115 | if (!VirtualFree(ptr, 0, MEM_RELEASE)) | 115 | if (!VirtualFree(ptr, 0, MEM_RELEASE)) |
| 116 | LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); | 116 | NGLOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n{}", GetLastErrorMsg()); |
| 117 | #else | 117 | #else |
| 118 | munmap(ptr, size); | 118 | munmap(ptr, size); |
| 119 | #endif | 119 | #endif |
| @@ -134,7 +134,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) { | |||
| 134 | #ifdef _WIN32 | 134 | #ifdef _WIN32 |
| 135 | DWORD oldValue; | 135 | DWORD oldValue; |
| 136 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) | 136 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) |
| 137 | LOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n%s", GetLastErrorMsg()); | 137 | NGLOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n{}", GetLastErrorMsg()); |
| 138 | #else | 138 | #else |
| 139 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); | 139 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); |
| 140 | #endif | 140 | #endif |
| @@ -145,7 +145,7 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) { | |||
| 145 | DWORD oldValue; | 145 | DWORD oldValue; |
| 146 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, | 146 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, |
| 147 | &oldValue)) | 147 | &oldValue)) |
| 148 | LOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n%s", GetLastErrorMsg()); | 148 | NGLOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n{}", GetLastErrorMsg()); |
| 149 | #else | 149 | #else |
| 150 | mprotect(ptr, size, | 150 | mprotect(ptr, size, |
| 151 | allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); | 151 | allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); |
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index 3a6ef8c27..ab0154133 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -25,7 +25,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { | |||
| 25 | std::vector<std::string> key_value; | 25 | std::vector<std::string> key_value; |
| 26 | Common::SplitString(pair, KEY_VALUE_SEPARATOR, key_value); | 26 | Common::SplitString(pair, KEY_VALUE_SEPARATOR, key_value); |
| 27 | if (key_value.size() != 2) { | 27 | if (key_value.size() != 2) { |
| 28 | LOG_ERROR(Common, "invalid key pair %s", pair.c_str()); | 28 | NGLOG_ERROR(Common, "invalid key pair {}", pair); |
| 29 | continue; | 29 | continue; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| @@ -64,7 +64,7 @@ std::string ParamPackage::Serialize() const { | |||
| 64 | std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { | 64 | std::string ParamPackage::Get(const std::string& key, const std::string& default_value) const { |
| 65 | auto pair = data.find(key); | 65 | auto pair = data.find(key); |
| 66 | if (pair == data.end()) { | 66 | if (pair == data.end()) { |
| 67 | LOG_DEBUG(Common, "key %s not found", key.c_str()); | 67 | NGLOG_DEBUG(Common, "key '{}' not found", key); |
| 68 | return default_value; | 68 | return default_value; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| @@ -74,14 +74,14 @@ std::string ParamPackage::Get(const std::string& key, const std::string& default | |||
| 74 | int ParamPackage::Get(const std::string& key, int default_value) const { | 74 | int ParamPackage::Get(const std::string& key, int default_value) const { |
| 75 | auto pair = data.find(key); | 75 | auto pair = data.find(key); |
| 76 | if (pair == data.end()) { | 76 | if (pair == data.end()) { |
| 77 | LOG_DEBUG(Common, "key %s not found", key.c_str()); | 77 | NGLOG_DEBUG(Common, "key '{}' not found", key); |
| 78 | return default_value; | 78 | return default_value; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | try { | 81 | try { |
| 82 | return std::stoi(pair->second); | 82 | return std::stoi(pair->second); |
| 83 | } catch (const std::logic_error&) { | 83 | } catch (const std::logic_error&) { |
| 84 | LOG_ERROR(Common, "failed to convert %s to int", pair->second.c_str()); | 84 | NGLOG_ERROR(Common, "failed to convert {} to int", pair->second); |
| 85 | return default_value; | 85 | return default_value; |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| @@ -89,14 +89,14 @@ int ParamPackage::Get(const std::string& key, int default_value) const { | |||
| 89 | float ParamPackage::Get(const std::string& key, float default_value) const { | 89 | float ParamPackage::Get(const std::string& key, float default_value) const { |
| 90 | auto pair = data.find(key); | 90 | auto pair = data.find(key); |
| 91 | if (pair == data.end()) { | 91 | if (pair == data.end()) { |
| 92 | LOG_DEBUG(Common, "key %s not found", key.c_str()); | 92 | NGLOG_DEBUG(Common, "key {} not found", key); |
| 93 | return default_value; | 93 | return default_value; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | try { | 96 | try { |
| 97 | return std::stof(pair->second); | 97 | return std::stof(pair->second); |
| 98 | } catch (const std::logic_error&) { | 98 | } catch (const std::logic_error&) { |
| 99 | LOG_ERROR(Common, "failed to convert %s to float", pair->second.c_str()); | 99 | NGLOG_ERROR(Common, "failed to convert {} to float", pair->second); |
| 100 | return default_value; | 100 | return default_value; |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 124a8937f..96c52e3ba 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -107,7 +107,7 @@ std::string StringFromFormat(const char* format, ...) { | |||
| 107 | #else | 107 | #else |
| 108 | va_start(args, format); | 108 | va_start(args, format); |
| 109 | if (vasprintf(&buf, format, args) < 0) | 109 | if (vasprintf(&buf, format, args) < 0) |
| 110 | LOG_ERROR(Common, "Unable to allocate memory for string"); | 110 | NGLOG_ERROR(Common, "Unable to allocate memory for string"); |
| 111 | va_end(args); | 111 | va_end(args); |
| 112 | 112 | ||
| 113 | std::string temp = buf; | 113 | std::string temp = buf; |
| @@ -347,7 +347,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& | |||
| 347 | 347 | ||
| 348 | iconv_t const conv_desc = iconv_open("UTF-8", fromcode); | 348 | iconv_t const conv_desc = iconv_open("UTF-8", fromcode); |
| 349 | if ((iconv_t)(-1) == conv_desc) { | 349 | if ((iconv_t)(-1) == conv_desc) { |
| 350 | LOG_ERROR(Common, "Iconv initialization failure [%s]: %s", fromcode, strerror(errno)); | 350 | NGLOG_ERROR(Common, "Iconv initialization failure [{}]: {}", fromcode, strerror(errno)); |
| 351 | iconv_close(conv_desc); | 351 | iconv_close(conv_desc); |
| 352 | return {}; | 352 | return {}; |
| 353 | } | 353 | } |
| @@ -376,7 +376,7 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>& | |||
| 376 | ++src_buffer; | 376 | ++src_buffer; |
| 377 | } | 377 | } |
| 378 | } else { | 378 | } else { |
| 379 | LOG_ERROR(Common, "iconv failure [%s]: %s", fromcode, strerror(errno)); | 379 | NGLOG_ERROR(Common, "iconv failure [{}]: {}", fromcode, strerror(errno)); |
| 380 | break; | 380 | break; |
| 381 | } | 381 | } |
| 382 | } | 382 | } |
| @@ -395,7 +395,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { | |||
| 395 | 395 | ||
| 396 | iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); | 396 | iconv_t const conv_desc = iconv_open("UTF-16LE", "UTF-8"); |
| 397 | if ((iconv_t)(-1) == conv_desc) { | 397 | if ((iconv_t)(-1) == conv_desc) { |
| 398 | LOG_ERROR(Common, "Iconv initialization failure [UTF-8]: %s", strerror(errno)); | 398 | NGLOG_ERROR(Common, "Iconv initialization failure [UTF-8]: {}", strerror(errno)); |
| 399 | iconv_close(conv_desc); | 399 | iconv_close(conv_desc); |
| 400 | return {}; | 400 | return {}; |
| 401 | } | 401 | } |
| @@ -424,7 +424,7 @@ std::u16string UTF8ToUTF16(const std::string& input) { | |||
| 424 | ++src_buffer; | 424 | ++src_buffer; |
| 425 | } | 425 | } |
| 426 | } else { | 426 | } else { |
| 427 | LOG_ERROR(Common, "iconv failure [UTF-8]: %s", strerror(errno)); | 427 | NGLOG_ERROR(Common, "iconv failure [UTF-8]: {}", strerror(errno)); |
| 428 | break; | 428 | break; |
| 429 | } | 429 | } |
| 430 | } | 430 | } |