#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2021 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_STORAGE_FILESYSTEM_FILEMANAGERBACKEND_H #define NUCLEX_STORAGE_FILESYSTEM_FILEMANAGERBACKEND_H #include "Nuclex/Storage/Config.h" #include // std::weak_ptr #include // for std::map #include // for std::string #include // for std::vector namespace Nuclex { namespace Storage { namespace FileSystem { // ------------------------------------------------------------------------------------------- // class Container; class File; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Storage::FileSystem namespace Nuclex { namespace Storage { namespace FileSystem { // ------------------------------------------------------------------------------------------- // /// Private implementation of the file manager class FileManagerBackend { /// Initializes a new backend for the file manager public: FileManagerBackend() = default; /// Frees all resources owned by the file manager backend public: ~FileManagerBackend() = default; /// Creates a new file instance for the specified path /// Path of the file that will be accessed /// /// For normal files on the operating system's file system, the path should be /// the shortest absolute path to the same. For files in archives, instead of /// a directory separator an unlikely (but consistent) unicode character may be /// used instead to mark the transition from normal file to archive /// (i.e. /opt/awesome-game/data.zip#textures/logo.png where # is a specific /// unicode character that's unlikely to appear in actual files) /// public: std::shared_ptr RegisterFile(const std::string &path); /// /// Notifies the backend that the file with the specified path is no longer being accessed /// /// Path of the file that is no longer accessed /// /// This method is called from the destructor of the File class and notifies /// the file manager backend that it can remove the file from its map (otherwise /// detached weak_ptrs could accumulate without any limit). /// public: void EliminateFile(const std::string &path) throw(); /// /// Notifies the backend that a file has been moved or renamed /// /// Original absolute path of the file /// New absolute path of the file public: void MoveOrRenameFile(const std::string &originalPath, const std::string &newPath); /// A map that allows looking up open files by their absolute paths private: typedef std::map> PathToFileMap; /// Files that are currently being accessed private: PathToFileMap openFiles; /// Whether all file accesses should be recorded private: bool listPathAccesses; /// List into which all file accesses are written if recording is enabled private: std::vector pathAccesses; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Storage::FileSystem #endif // NUCLEX_STORAGE_FILESYSTEM_FILEMANAGERBACKEND_H