#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_CONTAINER_H #define NUCLEX_STORAGE_FILESYSTEM_CONTAINER_H #include "../Config.h" #include #include #include // Safety check for programmers using Windows // // Windows.h has the bad habit of globally renaming symbols through a #define. // When you write myContainer.CreateFile(), what the compiler gets to see is actually // myContainer.CreateFileW(). // // If you're developing for Windows and included Windows.h together with Container.h, // either the compiler will complain because the Container class doesn't have a method // called CreateFileW() or the symbols in Container.h will have been renamed, too, // causing linker errors. // // Solution: do not include Windows.h // (or #undef CreateFile + #undef DeleteFile if you must) // (but really, don't include Windows.h, it's slow and pollutes the global namespace) #if defined(CreateFile) #error "CreateFile is globally defined to something else, this WILL cause errors" #endif #if defined(DeleteFile) #error "DeleteFile is globally defined to something else, this WILL cause errors" #endif namespace Nuclex { namespace Storage { namespace FileSystem { // ------------------------------------------------------------------------------------------- // class File; class ContainerFileCodec; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Storage::FileSystem namespace Nuclex { namespace Storage { namespace FileSystem { // ------------------------------------------------------------------------------------------- // /// Contains other files or containers /// /// Containers are usually plain OS-level directories, but can also be /// archive files (i.e. .zip, .7z) or any other resource that behaves like /// a file system. /// class Container { /// Initializes a new container public: NUCLEX_STORAGE_API Container() = default; /// Destroys the file system interface public: NUCLEX_STORAGE_API virtual ~Container() = default; /// Returns the name of the container /// The container's name public: virtual const std::string &GetName() const = 0; /// Returns the path the container is stored at in the native format /// The container's absolute path in the native OS format public: virtual const std::string &GetNativePath() const = 0; /// Creates a list of containers below this one (i.e. subdirectories) /// Wild card by which to filter the enumerated containers /// A list of all containers below this one matching the wildcard public: virtual std::vector EnumerateContainers( const std::string &wildcard = u8"*" ) const = 0; /// Creates a list of all files in this container /// Wild card by which to filter the enumerated files /// A list of all files in this container matching the wildcard public: virtual std::vector EnumerateFiles( const std::string &wildcard = u8"*" ) const = 0; /// Accesses a child container of this container /// Name of the child container that will be accessed /// The child container with the specified name public: virtual std::shared_ptr AccessContainer(const std::string &name) = 0; /// Accesses a child container of this container /// Name of the child container that will be accessed /// The childcontainer with the specified name public: virtual std::shared_ptr AccessContainer( const std::string &name ) const = 0; #if 0 /// Retrieves a list of the containers located in this container /// Wildcard of the containers to list /// A list of all containers matching the wildcard public: virtual std::vector< std::shared_ptr > GetContainers( const std::string &wildcard = std::string() ) const = 0; /// Retrieves a list of the containers located in this container /// Wildcard of the containers to list /// A list of all containers matching the wildcard public: virtual std::vector< std::shared_ptr > GetContainers( const std::string &wildcard = std::string() ) = 0; /// Retrieves the container with the specified name /// Name of the container that will be retrieved /// The container with the specified name public: virtual std::shared_ptr GetContainer( const std::string &name ) const = 0; /// Retrieves the container with the specified name /// Name of the container that will be retrieved /// The container with the specified name public: virtual std::shared_ptr GetContainer(const std::string &name) = 0; /// Checks if the container contains the specified child container /// Child container the container will be checked for /// True if the container has a child container with the specified name public: virtual bool HasContainer(const std::string &name) const = 0; /// Creates a new container in this container /// Name of the created container /// The created container public: virtual std::shared_ptr CreateContainer(const std::string &name) = 0; /// Deletes a container in this container /// Name of the deleted container /// True if the container was deleted, false if it didn't exist public: virtual bool DeleteContainer(const std::string &name) = 0; /// Retrieves a list of the files located in this container /// Wildcard of the files to list /// A list of all files matching the wildcard public: virtual std::vector< std::shared_ptr > GetFiles( const std::string &wildcard = std::string() ) const = 0; /// Retrieves a list of the files located in this container /// Wildcard of the files to list /// A list of all files matching the wildcard public: virtual std::vector< std::shared_ptr > GetFiles( const std::string &wildcard = std::string() ) = 0; /// Retrieves the file with the specified name /// Name of the file that will be retrieved /// The file with the specified name public: virtual std::shared_ptr GetFile( const std::string &name ) const = 0; /// Retrieves the file with the specified name /// Name of the file that will be retrieved /// The file with the specified name public: virtual std::shared_ptr GetFile(const std::string &name) = 0; /// Checks if the container contains the specified file /// File the container will be checked for /// True if the container contains a file with the specified name public: virtual bool HasFile(const std::string &name) const = 0; /// Retrieves the file with the specified name /// Name of the file that will be retrieved /// The file with the specified name public: virtual std::shared_ptr CreateFile(const std::string &name) = 0; /// Deletes the file with the specified name /// Name of the file that will be deleted /// True if the file was deleted, false if it didn't exist public: virtual bool DeleteFile(const std::string &name) = 0; /// Container file codecs the container uses to open files as containers protected: std::shared_ptr Codecs; #endif }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Storage::FileSystem #endif // NUCLEX_STORAGE_FILESYSTEM_CONTAINER_H