Commit 1338ecf6 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

fs: Device: Reintroduce a isPresent method

In case the device is unmounted but still present, we wouldn't return a
nullptr device, and therefor need a way to know that the device is not
usable
parent fff0f2d0
......@@ -32,6 +32,7 @@ public:
virtual ~IDevice() = default;
virtual const std::string& uuid() const = 0;
virtual bool isRemovable() const = 0;
virtual bool isPresent() const = 0;
virtual const std::string& mountpoint() const = 0;
};
}
......@@ -43,6 +43,7 @@ Device::Device( const std::string& devicePath )
: m_device( devicePath )
, m_uuid( "fake uuid" )
, m_mountpoint( "/mnt/fixme" )
, m_present( true )
{
}
......@@ -56,6 +57,11 @@ bool Device::isRemovable() const
return false;
}
bool Device::isPresent() const
{
return m_present;
}
const std::string&Device::mountpoint() const
{
return m_mountpoint;
......
......@@ -36,6 +36,7 @@ public:
virtual const std::string& uuid() const override;
virtual bool isRemovable() const override;
virtual bool isPresent() const override;
virtual const std::string& mountpoint() const override;
///
......@@ -57,6 +58,7 @@ private:
std::string m_device;
std::string m_uuid;
std::string m_mountpoint;
bool m_present;
};
}
......@@ -90,16 +90,19 @@ class Device : public fs::IDevice
{
public:
Device( const std::string& mountpoint, const std::string& uuid ) : m_uuid( uuid ),
m_removable( false ), m_mountpoint( mountpoint ) {}
m_removable( false ), m_present( true ), m_mountpoint( mountpoint ) {}
virtual const std::string& uuid() const override { return m_uuid; }
virtual bool isRemovable() const override { return m_removable; }
virtual bool isPresent() const override { return m_present; }
virtual const std::string& mountpoint() const override { return m_mountpoint; }
void setRemovable( bool value ) { m_removable = value; }
void setPresent( bool value ) { m_present = value; }
private:
std::string m_uuid;
bool m_removable;
bool m_present;
std::string m_mountpoint;
};
......
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