Skip to content

Commit

Permalink
Move Archive interface out of iarchive.h
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 50 deletions.
46 changes: 0 additions & 46 deletions include/iarchive.h
Expand Up @@ -57,49 +57,3 @@ class ArchiveTextFile :
};
typedef std::shared_ptr<ArchiveTextFile> ArchiveTextFilePtr;

/**
* 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;
1 change: 0 additions & 1 deletion include/ifilesystem.h
Expand Up @@ -19,7 +19,6 @@ class ArchiveFile;
typedef std::shared_ptr<ArchiveFile> ArchiveFilePtr;
class ArchiveTextFile;
typedef std::shared_ptr<ArchiveTextFile> ArchiveTextFilePtr;
class Archive;

namespace vfs
{
Expand Down
51 changes: 51 additions & 0 deletions radiant/vfs/Archive.h
@@ -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;

2 changes: 1 addition & 1 deletion radiant/vfs/DirectoryArchive.h
@@ -1,6 +1,6 @@
#pragma once

#include "iarchive.h"
#include "Archive.h"

/**
* greebo: This wraps around a certain path in the "real"
Expand Down
2 changes: 1 addition & 1 deletion radiant/vfs/Doom3FileSystem.h
@@ -1,6 +1,6 @@
#pragma once

#include "iarchive.h"
#include "Archive.h"
#include "ifilesystem.h"

namespace vfs
Expand Down
2 changes: 1 addition & 1 deletion radiant/vfs/GenericFileSystem.h
@@ -1,6 +1,6 @@
#pragma once

#include "iarchive.h"
#include "Archive.h"
#include "string/string.h"
#include "os/path.h"

Expand Down

0 comments on commit 6b62c68

Please sign in to comment.