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

FS factory: Add a isPathSupported method

parent dbea5c21
......@@ -62,6 +62,12 @@ namespace factory
/// \brief refresh Will cause any FS cache to be refreshed.
///
virtual bool refreshDevices() = 0;
///
/// \brief isPathSupported Checks for support of a path by this FS facotry
/// \param path The path to probe for support
/// \return True if supported, false otherwise
///
virtual bool isPathSupported( const std::string& path ) const = 0;
};
}
......
......@@ -53,7 +53,8 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
{
LOG_INFO( "Adding to discovery list: ", entryPoint );
// Assume :// denotes a scheme that isn't a file path, and refuse to discover it.
if ( entryPoint.find( "://" ) != std::string::npos )
if ( m_fsFactory->isPathSupported( entryPoint ) == false )
return false;
std::shared_ptr<fs::IDirectory> fsDir = m_fsFactory->createDirectory( entryPoint );
......@@ -98,6 +99,8 @@ bool FsDiscoverer::reload()
bool FsDiscoverer::reload( const std::string& entryPoint )
{
if ( m_fsFactory->isPathSupported( entryPoint ) == false )
return false;
LOG_INFO( "Reloading folder ", entryPoint );
// Start by checking if previously known devices have been plugged/unplugged
if ( checkDevices() == false )
......
......@@ -125,6 +125,14 @@ bool FileSystemFactory::refreshDevices()
return true;
}
bool FileSystemFactory::isPathSupported( const std::string& path ) const
{
auto it = path.find( "://" );
if ( it == std::string::npos )
return true;
return path.compare( 0, 7, "file://" ) == 0;
}
}
}
......@@ -46,6 +46,7 @@ namespace factory
virtual std::shared_ptr<fs::IDevice> createDevice( const std::string& uuid ) override;
virtual std::shared_ptr<fs::IDevice> createDeviceFromPath( const std::string& path ) override;
virtual bool refreshDevices() override;
virtual bool isPathSupported( const std::string& path ) const override;
private:
std::unordered_map<std::string, std::shared_ptr<fs::IDirectory>> m_dirs;
......
......@@ -199,6 +199,11 @@ struct FileSystemFactory : public factory::IFileSystem
return device( path );
}
virtual bool isPathSupported( const std::string& ) const override
{
return true;
}
std::vector<std::shared_ptr<Device>> devices;
};
......@@ -331,6 +336,11 @@ public:
{
return false;
}
virtual bool isPathSupported( const std::string& ) const override
{
return true;
}
};
}
......
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