vfs: Make type hierarchy objects classes instead of structs
struct should be used when the data type is very simple or otherwise has no invariants associated with it. Given these are used to form a hierarchy, class should be used instead.
This commit is contained in:
parent
424e90f0f5
commit
cf0a7cd1c1
4 changed files with 16 additions and 10 deletions
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
struct VfsFilesystem;
|
class VfsDirectory;
|
||||||
struct VfsFile;
|
class VfsFile;
|
||||||
struct VfsDirectory;
|
class VfsFilesystem;
|
||||||
|
|
||||||
// Convenience typedefs to use Vfs* interfaces
|
// Convenience typedefs to use Vfs* interfaces
|
||||||
using VirtualFilesystem = std::shared_ptr<VfsFilesystem>;
|
using VirtualFilesystem = std::shared_ptr<VfsFilesystem>;
|
||||||
|
@ -34,7 +34,8 @@ enum class VfsEntryType {
|
||||||
// A class representing an abstract filesystem. A default implementation given the root VirtualDir
|
// A class representing an abstract filesystem. A default implementation given the root VirtualDir
|
||||||
// is provided for convenience, but if the Vfs implementation has any additional state or
|
// is provided for convenience, but if the Vfs implementation has any additional state or
|
||||||
// functionality, they will need to override.
|
// functionality, they will need to override.
|
||||||
struct VfsFilesystem : NonCopyable {
|
class VfsFilesystem : NonCopyable {
|
||||||
|
public:
|
||||||
VfsFilesystem(VirtualDir root);
|
VfsFilesystem(VirtualDir root);
|
||||||
virtual ~VfsFilesystem();
|
virtual ~VfsFilesystem();
|
||||||
|
|
||||||
|
@ -81,7 +82,8 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class representing a file in an abstract filesystem.
|
// A class representing a file in an abstract filesystem.
|
||||||
struct VfsFile : NonCopyable {
|
class VfsFile : NonCopyable {
|
||||||
|
public:
|
||||||
virtual ~VfsFile();
|
virtual ~VfsFile();
|
||||||
|
|
||||||
// Retrieves the file name.
|
// Retrieves the file name.
|
||||||
|
@ -179,7 +181,8 @@ struct VfsFile : NonCopyable {
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class representing a directory in an abstract filesystem.
|
// A class representing a directory in an abstract filesystem.
|
||||||
struct VfsDirectory : NonCopyable {
|
class VfsDirectory : NonCopyable {
|
||||||
|
public:
|
||||||
virtual ~VfsDirectory();
|
virtual ~VfsDirectory();
|
||||||
|
|
||||||
// Retrives the file located at path as if the current directory was root. Returns nullptr if
|
// Retrives the file located at path as if the current directory was root. Returns nullptr if
|
||||||
|
@ -295,7 +298,8 @@ protected:
|
||||||
|
|
||||||
// A convenience partial-implementation of VfsDirectory that stubs out methods that should only work
|
// A convenience partial-implementation of VfsDirectory that stubs out methods that should only work
|
||||||
// if writable. This is to avoid redundant empty methods everywhere.
|
// if writable. This is to avoid redundant empty methods everywhere.
|
||||||
struct ReadOnlyVfsDirectory : public VfsDirectory {
|
class ReadOnlyVfsDirectory : public VfsDirectory {
|
||||||
|
public:
|
||||||
bool IsWritable() const override;
|
bool IsWritable() const override;
|
||||||
bool IsReadable() const override;
|
bool IsReadable() const override;
|
||||||
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
std::shared_ptr<VfsDirectory> CreateSubdirectory(std::string_view name) override;
|
||||||
|
|
|
@ -15,7 +15,8 @@ namespace FileSys {
|
||||||
// Similar to seeking to an offset.
|
// Similar to seeking to an offset.
|
||||||
// If the file is writable, operations that would write past the end of the offset file will expand
|
// If the file is writable, operations that would write past the end of the offset file will expand
|
||||||
// the size of this wrapper.
|
// the size of this wrapper.
|
||||||
struct OffsetVfsFile : public VfsFile {
|
class OffsetVfsFile : public VfsFile {
|
||||||
|
public:
|
||||||
OffsetVfsFile(std::shared_ptr<VfsFile> file, size_t size, size_t offset = 0,
|
OffsetVfsFile(std::shared_ptr<VfsFile> file, size_t size, size_t offset = 0,
|
||||||
std::string new_name = "", VirtualDir new_parent = nullptr);
|
std::string new_name = "", VirtualDir new_parent = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace FileSys {
|
||||||
|
|
||||||
// An implementation of VfsDirectory that maintains two vectors for subdirectories and files.
|
// An implementation of VfsDirectory that maintains two vectors for subdirectories and files.
|
||||||
// Vector data is supplied upon construction.
|
// Vector data is supplied upon construction.
|
||||||
struct VectorVfsDirectory : public VfsDirectory {
|
class VectorVfsDirectory : public VfsDirectory {
|
||||||
|
public:
|
||||||
explicit VectorVfsDirectory(std::vector<VirtualFile> files = {},
|
explicit VectorVfsDirectory(std::vector<VirtualFile> files = {},
|
||||||
std::vector<VirtualDir> dirs = {}, VirtualDir parent = nullptr,
|
std::vector<VirtualDir> dirs = {}, VirtualDir parent = nullptr,
|
||||||
std::string name = "");
|
std::string name = "");
|
||||||
|
|
|
@ -23,7 +23,7 @@ class HLERequestContext;
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
struct VfsFilesystem;
|
class VfsFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
|
Loading…
Reference in a new issue