roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
filesystem.cpp
Go to the documentation of this file.
2
3namespace roo_io {
4
7 if (policy == kMountDisabled) {
8 return Mount(kNotMounted);
9 }
11 std::shared_ptr<MountImpl> existing = mount_.lock();
12 if (existing != nullptr) {
13 return Mount(existing, read_only);
14 }
16 if (mount_result.status != kOk) {
17 Status status = mount_result.status;
19 // Try to return a more specific status message.
20 status = kNoMedia;
21 }
22 return Mount(status);
23 }
24 auto impl = std::shared_ptr<MountImpl>(mount_result.mount.release());
25 if (impl == nullptr) {
27 }
28 mount_ = impl;
29 if (unmounting_policy_ == kUnmountLazily) {
30 lazy_unmount_ = impl;
31 }
32 return Mount(impl, read_only);
33}
34
36 unmounting_policy_ = unmounting_policy;
37 if (unmounting_policy_ == kUnmountEagerly) {
38 lazy_unmount_.reset();
39 } else {
40 lazy_unmount_ = mount_.lock();
41 }
42}
43
45 auto m = mount_.lock();
46 if (m != nullptr) {
47 m->deactivate();
48 }
49 mount_.reset();
50 lazy_unmount_.reset();
52}
53
54const char* GetFileName(const char* path) {
55 size_t i = 0;
56 size_t pos = 0;
57 char* p = (char*)path;
58 while (*p) {
59 i++;
60 if (*p == '/' || *p == '\\') {
61 pos = i;
62 }
63 p++;
64 }
65 return path + pos;
66}
67
68} // namespace roo_io
virtual MediaPresence checkMediaPresence()=0
virtual void unmountImpl()=0
void setUnmountingPolicy(UnmountingPolicy unmounting_policy)
virtual MountImpl::MountResult mountImpl(std::function< void()> unmount_fn)=0
MountingPolicy mountingPolicy() const
Definition filesystem.h:87
Definition byte.h:6
const char * GetFileName(const char *path)
roo::basic_string_view< CharT, Traits > basic_string_view
Definition string_view.h:8
Status
Definition status.h:7
@ kGenericMountError
Definition status.h:17
@ kNoMedia
Definition status.h:64
@ kOk
Definition status.h:8
@ kNotMounted
Definition status.h:11