Commit bea8f8b5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

FileSystem: Add a method to create an IFile representation of a file

parent 7ca0977b
......@@ -5,6 +5,7 @@
namespace fs
{
class IDirectory;
class IFile;
}
namespace factory
......@@ -14,5 +15,6 @@ namespace factory
public:
virtual ~IFileSystem() = default;
virtual std::unique_ptr<fs::IDirectory> createDirectory( const std::string& path ) = 0;
virtual std::unique_ptr<fs::IFile> createFile( const std::string& path, const std::string& fileName ) = 0;
};
}
#include "factory/FileSystem.h"
#include "filesystem/IDirectory.h"
#include "filesystem/IFile.h"
#if defined(__linux__) || defined(__APPLE__)
# include "filesystem/unix/Directory.h"
# include "filesystem/unix/File.h"
#else
# error No filesystem implementation for this architecture
#endif
......@@ -15,4 +17,11 @@ std::unique_ptr<fs::IDirectory> FileSystemDefaultFactory::createDirectory( const
return std::unique_ptr<fs::IDirectory>( new fs::Directory( path ) );
}
std::unique_ptr<fs::IFile> FileSystemDefaultFactory::createFile(const std::string& path, const std::string& fileName)
{
return std::unique_ptr<fs::IFile>( new fs::File( path, fileName ) );
}
}
......@@ -8,5 +8,6 @@ namespace factory
{
public:
virtual std::unique_ptr<fs::IDirectory> createDirectory( const std::string& path ) override;
virtual std::unique_ptr<fs::IFile> createFile( const std::string& path, const std::string& fileName ) override;
};
}
......@@ -13,7 +13,9 @@ namespace fs
virtual ~IDirectory() = default;
// Returns the absolute path to this directory
virtual const std::string& path() const = 0;
/// Returns a list of absolute files path
virtual const std::vector<std::string>& files() const = 0;
/// Returns a list of absolute path to this folder subdirectories
virtual const std::vector<std::string>& dirs() const = 0;
virtual unsigned int lastModificationDate() const = 0;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment