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

fs factory: Return folders as shared_ptr

parent 3972cbce
......@@ -41,7 +41,7 @@ namespace factory
/// \brief createDirectory creates a representation of a directory
/// \param path An absolute path to a directory
///
virtual std::unique_ptr<fs::IDirectory> createDirectory( const std::string& path ) = 0;
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& path ) = 0;
///
/// \brief createFile creates a representation of a file
/// \param fileName an absolute path to a file
......
......@@ -54,7 +54,7 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
return true;
}
// Otherwise, create a directory, and check it for modifications
std::unique_ptr<fs::IDirectory> fsDir;
std::shared_ptr<fs::IDirectory> fsDir;
try
{
fsDir = m_fsFactory->createDirectory( entryPoint );
......
......@@ -37,9 +37,9 @@
namespace factory
{
std::unique_ptr<fs::IDirectory> FileSystemDefaultFactory::createDirectory( const std::string& path )
std::shared_ptr<fs::IDirectory> FileSystemDefaultFactory::createDirectory( const std::string& path )
{
return std::unique_ptr<fs::IDirectory>( new fs::Directory( path ) );
return std::shared_ptr<fs::IDirectory>( new fs::Directory( path ) );
}
std::unique_ptr<fs::IFile> FileSystemDefaultFactory::createFile(const std::string& fileName)
......
......@@ -29,7 +29,7 @@ namespace factory
class FileSystemDefaultFactory : public IFileSystem
{
public:
virtual std::unique_ptr<fs::IDirectory> createDirectory( const std::string& path ) override;
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& path ) override;
virtual std::unique_ptr<fs::IFile> createFile( const std::string& fileName ) override;
};
}
......@@ -231,7 +231,7 @@ struct FileSystemFactory : public factory::IFileSystem
dirs.erase( it );
}
virtual std::unique_ptr<fs::IDirectory> createDirectory(const std::string& path) override
virtual std::shared_ptr<fs::IDirectory> createDirectory(const std::string& path) override
{
mock::Directory* res = nullptr;
if ( path == "." )
......@@ -246,7 +246,7 @@ struct FileSystemFactory : public factory::IFileSystem
}
if ( res == nullptr )
throw std::runtime_error("Invalid path");
return std::unique_ptr<fs::IDirectory>( new Directory( *res ) );
return std::shared_ptr<fs::IDirectory>( new Directory( *res ) );
}
virtual std::unique_ptr<fs::IFile> createFile( const std::string &filePath ) override
......@@ -307,7 +307,7 @@ public:
class NoopFsFactory : public factory::IFileSystem
{
public:
virtual std::unique_ptr<fs::IDirectory> createDirectory( const std::string& ) override
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& ) override
{
return nullptr;
}
......
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