Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Archive interface out of iarchive.h
The Archive interface is not actually used by anything outside of the radiant/vfs directory, so does not need to appear in an interface file.
- Loading branch information
Matthew Mott
committed
Feb 6, 2019
1 parent
37016de
commit 6b62c68
Showing
6 changed files
with
54 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include "iarchive.h" | ||
|
||
/** | ||
* Representation of an archive in the virtual filesystem. | ||
* This might be a PK4/ZIP file or a regular mod directory. | ||
* | ||
* \ingroup vfs | ||
*/ | ||
class Archive | ||
{ | ||
public: | ||
class Visitor | ||
{ | ||
public: | ||
virtual ~Visitor() {} | ||
|
||
// Invoked for each file in an Archive | ||
virtual void visitFile(const std::string& name) = 0; | ||
|
||
// Invoked for each directory in an Archive. Return true to skip the directory. | ||
virtual bool visitDirectory(const std::string& name, std::size_t depth) = 0; | ||
}; | ||
|
||
/// \brief destructor | ||
virtual ~Archive() {} | ||
|
||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened. | ||
/// Name comparisons are case-insensitive. | ||
virtual ArchiveFilePtr openFile(const std::string& name) = 0; | ||
|
||
/// \brief Returns a new object associated with the file identified by \p name, or 0 if the file cannot be opened. | ||
/// Name comparisons are case-insensitive. | ||
virtual ArchiveTextFilePtr openTextFile(const std::string& name) = 0; | ||
|
||
/// Returns true if the file identified by \p name can be opened. | ||
/// Name comparisons are case-insensitive. | ||
virtual bool containsFile(const std::string& name) = 0; | ||
|
||
/// \brief Performs a depth-first traversal of the archive tree starting at \p root. | ||
/// Traverses the entire tree if \p root is "". | ||
/// When a file is encountered, calls \c visitor.file passing the file name. | ||
/// When a directory is encountered, calls \c visitor.directory passing the directory name. | ||
/// Skips the directory if \c visitor.directory returned true. | ||
/// Root comparisons are case-insensitive. | ||
/// Names are mixed-case. | ||
virtual void traverse(Visitor& visitor, const std::string& root) = 0; | ||
}; | ||
typedef std::shared_ptr<Archive> ArchivePtr; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "iarchive.h" | ||
#include "Archive.h" | ||
#include "ifilesystem.h" | ||
|
||
namespace vfs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "iarchive.h" | ||
#include "Archive.h" | ||
#include "string/string.h" | ||
#include "os/path.h" | ||
|
||
|