-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisk.cc
44 lines (36 loc) · 1.07 KB
/
disk.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2011 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cros-disks/disk.h"
#include <algorithm>
namespace cros_disks {
namespace {
const char kUSBDriveName[] = "USB Drive";
const char kSDCardName[] = "SD Card";
const char kOpticalDiscName[] = "Optical Disc";
const char kMobileDeviceName[] = "Mobile Device";
const char kDVDName[] = "DVD";
const char kFallbackPresentationName[] = "External Drive";
} // namespace
std::string Disk::GetPresentationName() const {
if (!label.empty()) {
std::string name = label;
std::replace(name.begin(), name.end(), '/', '_');
return name;
}
switch (media_type) {
case DeviceType::kUSB:
return kUSBDriveName;
case DeviceType::kSD:
return kSDCardName;
case DeviceType::kOpticalDisc:
return kOpticalDiscName;
case DeviceType::kMobile:
return kMobileDeviceName;
case DeviceType::kDVD:
return kDVDName;
default:
return kFallbackPresentationName;
}
}
} // namespace cros_disks