| 403 | CloseHandle(handle); |
| 404 | _openName = fullName; |
| 405 | |
| 406 | _openBeforeOpenCallback = beforeOpen; |
| 407 | _openContext = context; |
| 408 | _files.Clear(); |
| 409 | _error = false; |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | // All banks are locked by default; an app that wants a bank unloadable must unlock it. |
| 414 | void QFBank::Lock() const |
| 415 | { |
| 416 | _locked = true; |
| 417 | Load(); |
| 418 | } |
| 419 | |
| 420 | void QFBank::Unlock() const |
| 421 | { |
| 422 | _locked = false; |
| 423 | if (_fileAccess && _fileAccess->RefCounter() == 1) |
| 424 | { |
| 425 | Unload(); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | bool QFBank::CanBeUnloaded() const |
| 430 | { |
| 431 | return _fileAccess && _fileAccess->RefCounter() == 1; |
| 432 | } |
| 433 | |
| 434 | // Meyer's singleton for bank functions - no global constructor! |
| 435 | #pragma clang diagnostic push |
| 436 | #pragma clang diagnostic ignored "-Wexit-time-destructors" |
| 437 | static QFBankFunctions& GetDefaultQFBankFunctions() |
| 438 | { |
| 439 | static QFBankFunctions instance; |
| 440 | return instance; |
| 441 | } |
| 442 | #pragma clang diagnostic pop |
| 443 | |
| 444 | // Constant-init nullptr (SIOF-safe); DefaultFunctions() falls back to a no-op base |
| 445 | // instance until a real implementation registers. |
| 446 | QFBankFunctions* QFBank::_defaultFunctions = nullptr; |
| 447 | |
| 448 | // Platform directory separator: entries inside PBO banks are stored |
| 449 | // with the native separator so that lookups work without conversion. |
| 450 | #ifdef __GNUC__ |
| 451 | static constexpr char NATIVE_DIR = UNIX_DIR; |
| 452 | static constexpr char FOREIGN_DIR = WIN_DIR; |
| 453 | static const RString NATIVE_DIR_STR("/"); |
| 454 | #else |
| 455 | static constexpr char NATIVE_DIR = WIN_DIR; |
| 456 | static constexpr char FOREIGN_DIR = UNIX_DIR; |
| 457 | static const RString NATIVE_DIR_STR("\\"); |
| 458 | #endif |
| 459 | |
| 460 | static inline RStringB ConvertDirSlash(RStringB name) |
| 461 | { |
| 462 | const char* change = strchr(name, FOREIGN_DIR); |
nothing calls this directly
no test coverage detected