| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHOS_DISKS_UDEV_DEVICE_H_ |
| 6 #define CROS_DISKS_UDEV_DEVICE_H_ |
| 7 |
| 8 #include <base/basictypes.h> |
| 9 #include <iostream> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "disk.h" |
| 14 |
| 15 struct udev_device; |
| 16 |
| 17 namespace cros_disks { |
| 18 |
| 19 // A utility class that helps query information about a udev device. |
| 20 class UdevDevice { |
| 21 public: |
| 22 |
| 23 explicit UdevDevice(struct udev_device *dev); |
| 24 ~UdevDevice(); |
| 25 |
| 26 // Gets the string value of a device attribute. |
| 27 std::string GetAttribute(const char *key) const; |
| 28 |
| 29 // Checks if the value of a device attribute represents a Boolean true. |
| 30 bool IsAttributeTrue(const char *key) const; |
| 31 |
| 32 // Checks if a device attribute exists. |
| 33 bool HasAttribute(const char *key) const; |
| 34 |
| 35 // Gets the string value of a device property. |
| 36 std::string GetProperty(const char *key) const; |
| 37 |
| 38 // Checks if the value of a device property represents a Boolean true. |
| 39 bool IsPropertyTrue(const char *key) const; |
| 40 |
| 41 // Checks if a device property exists. |
| 42 bool HasProperty(const char *key) const; |
| 43 |
| 44 // Gets the total and remaining capacity of the device. |
| 45 void GetSizeInfo(uint64 *total_size, uint64 *remaining_size) const; |
| 46 |
| 47 // Checks if any media is available in the device. |
| 48 bool IsMediaAvailable() const; |
| 49 |
| 50 // Gets the mounted paths for the device. |
| 51 std::vector<std::string> GetMountedPaths() const; |
| 52 |
| 53 // Gets the mounted paths for an input stream that has the |
| 54 // same format as /proc/mounts |
| 55 static std::vector<std::string> ParseMountedPaths( |
| 56 const std::string& device_path, std::istream& stream); |
| 57 |
| 58 // Returns a Disk object based on the device information. |
| 59 Disk ToDisk() const; |
| 60 |
| 61 private: |
| 62 |
| 63 bool IsValueBooleanTrue(const char *value) const; |
| 64 |
| 65 mutable struct udev_device *dev_; |
| 66 }; |
| 67 |
| 68 } // namespace cros_disks |
| 69 |
| 70 #endif // CROS_DISKS_UDEV_DEVICE_H_ |
| OLD | NEW |