diff options
author | Max Kellermann <max@musicpd.org> | 2018-06-04 17:08:04 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-06-04 17:23:55 +0200 |
commit | 640de5518bf7a2fa35aec38f466e16c4ed303f40 (patch) | |
tree | 01d29762c869f50cd5df3a6399a2895ede2a19d6 /src/lib | |
parent | a92c694f1be2a3e47dea9af1448bc798881c0d74 (diff) |
neighbor/udisks: move struct UdisksObject to UDisks2.hxx
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dbus/UDisks2.hxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/dbus/UDisks2.hxx b/src/lib/dbus/UDisks2.hxx index d4e8e6183..12b9449a3 100644 --- a/src/lib/dbus/UDisks2.hxx +++ b/src/lib/dbus/UDisks2.hxx @@ -20,7 +20,38 @@ #ifndef UDISKS2_HXX #define UDISKS2_HXX +#include <string> + #define UDISKS2_PATH "/org/freedesktop/UDisks2" #define UDISKS2_INTERFACE "org.freedesktop.UDisks2" +namespace UDisks2 { + +struct Object { + const std::string path; + + std::string drive_id, block_id; + + bool is_filesystem = false; + + explicit Object(const char *_path) noexcept + :path(_path) {} + + bool IsValid() const noexcept { + return is_filesystem && + (!drive_id.empty() || !block_id.empty()); + } + + std::string GetUri() const noexcept { + if (!drive_id.empty()) + return "udisks://" + drive_id; + else if (!block_id.empty()) + return "udisks://" + block_id; + else + return {}; + } +}; + +} // namespace UDisks2 + #endif |