OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium 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 #include "ppapi/cpp/file_ref.h" | |
6 | |
7 #include "ppapi/c/pp_errors.h" | |
8 #include "ppapi/cpp/completion_callback.h" | |
9 #include "ppapi/cpp/file_system.h" | |
10 #include "ppapi/cpp/module_impl.h" | |
11 | |
12 | |
13 namespace pp { | |
14 | |
15 namespace { | |
16 | |
17 template <> const char* interface_name<PPB_FileRef>() { | |
18 return PPB_FILEREF_INTERFACE; | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 FileRef::FileRef(PP_Resource resource) : Resource(resource) { | |
24 } | |
25 | |
26 FileRef::FileRef(PassRef, PP_Resource resource) { | |
27 PassRefFromConstructor(resource); | |
28 } | |
29 | |
30 FileRef::FileRef(const FileSystem& file_system, | |
31 const char* path) { | |
32 if (!has_interface<PPB_FileRef>()) | |
33 return; | |
34 PassRefFromConstructor(get_interface<PPB_FileRef>()->Create( | |
35 file_system.pp_resource(), path)); | |
36 } | |
37 | |
38 FileRef::FileRef(const FileRef& other) | |
39 : Resource(other) { | |
40 } | |
41 | |
42 PP_FileSystemType FileRef::GetFileSystemType() const { | |
43 if (!has_interface<PPB_FileRef>()) | |
44 return PP_FILESYSTEMTYPE_EXTERNAL; | |
45 return get_interface<PPB_FileRef>()->GetFileSystemType(pp_resource()); | |
46 } | |
47 | |
48 Var FileRef::GetName() const { | |
49 if (!has_interface<PPB_FileRef>()) | |
50 return Var(); | |
51 return Var(Var::PassRef(), | |
52 get_interface<PPB_FileRef>()->GetName(pp_resource())); | |
53 } | |
54 | |
55 Var FileRef::GetPath() const { | |
56 if (!has_interface<PPB_FileRef>()) | |
57 return Var(); | |
58 return Var(Var::PassRef(), | |
59 get_interface<PPB_FileRef>()->GetPath(pp_resource())); | |
60 } | |
61 | |
62 FileRef FileRef::GetParent() const { | |
63 if (!has_interface<PPB_FileRef>()) | |
64 return FileRef(); | |
65 return FileRef(PassRef(), | |
66 get_interface<PPB_FileRef>()->GetParent( | |
67 pp_resource())); | |
68 } | |
69 | |
70 int32_t FileRef::MakeDirectory(const CompletionCallback& cc) { | |
71 if (!has_interface<PPB_FileRef>()) | |
72 return PP_ERROR_NOINTERFACE; | |
73 return get_interface<PPB_FileRef>()->MakeDirectory( | |
74 pp_resource(), | |
75 PP_FALSE, // make_ancestors | |
76 cc.pp_completion_callback()); | |
77 } | |
78 | |
79 int32_t FileRef::MakeDirectoryIncludingAncestors( | |
80 const CompletionCallback& cc) { | |
81 if (!has_interface<PPB_FileRef>()) | |
82 return PP_ERROR_NOINTERFACE; | |
83 return get_interface<PPB_FileRef>()->MakeDirectory( | |
84 pp_resource(), | |
85 PP_TRUE, // make_ancestors | |
86 cc.pp_completion_callback()); | |
87 } | |
88 | |
89 int32_t FileRef::Touch(PP_Time last_access_time, | |
90 PP_Time last_modified_time, | |
91 const CompletionCallback& cc) { | |
92 if (!has_interface<PPB_FileRef>()) | |
93 return PP_ERROR_NOINTERFACE; | |
94 return get_interface<PPB_FileRef>()->Touch( | |
95 pp_resource(), last_access_time, last_modified_time, | |
96 cc.pp_completion_callback()); | |
97 } | |
98 | |
99 int32_t FileRef::Delete(const CompletionCallback& cc) { | |
100 if (!has_interface<PPB_FileRef>()) | |
101 return PP_ERROR_NOINTERFACE; | |
102 return get_interface<PPB_FileRef>()->Delete( | |
103 pp_resource(), cc.pp_completion_callback()); | |
104 } | |
105 | |
106 int32_t FileRef::Rename(const FileRef& new_file_ref, | |
107 const CompletionCallback& cc) { | |
Sang Ahn
2011/06/22 23:34:25
Funny indent.
| |
108 if (!has_interface<PPB_FileRef>()) | |
109 return PP_ERROR_NOINTERFACE; | |
110 return get_interface<PPB_FileRef>()->Rename( | |
111 pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback()); | |
112 } | |
113 | |
114 } // namespace pp | |
OLD | NEW |