OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 class FilesystemInterface { | 77 class FilesystemInterface { |
78 public: | 78 public: |
79 virtual ~FilesystemInterface() {} | 79 virtual ~FilesystemInterface() {} |
80 | 80 |
81 // This will attempt to delete the path located at filename. | 81 // This will attempt to delete the path located at filename. |
82 // It DCHECKs and returns false if the path points to a folder or a | 82 // It DCHECKs and returns false if the path points to a folder or a |
83 // non-existent file. | 83 // non-existent file. |
84 virtual bool DeleteFile(const Pathname &filename) = 0; | 84 virtual bool DeleteFile(const Pathname &filename) = 0; |
85 | 85 |
86 // Creates a directory. This will call itself recursively to create /foo/bar | |
87 // even if /foo does not exist. Returns true if the function succeeds. | |
88 virtual bool CreateFolder(const Pathname &pathname) = 0; | |
89 | |
90 // This moves a file from old_path to new_path, where "old_path" is a | 86 // This moves a file from old_path to new_path, where "old_path" is a |
91 // plain file. This DCHECKs and returns false if old_path points to a | 87 // plain file. This DCHECKs and returns false if old_path points to a |
92 // directory, and returns true if the function succeeds. | 88 // directory, and returns true if the function succeeds. |
93 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0; | 89 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0; |
94 | 90 |
95 // Returns true if pathname refers to a directory | 91 // Returns true if pathname refers to a directory |
96 virtual bool IsFolder(const Pathname& pathname) = 0; | 92 virtual bool IsFolder(const Pathname& pathname) = 0; |
97 | 93 |
98 // Returns true if pathname refers to a file | 94 // Returns true if pathname refers to a file |
99 virtual bool IsFile(const Pathname& pathname) = 0; | 95 virtual bool IsFile(const Pathname& pathname) = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
116 default_filesystem_ = filesystem; | 112 default_filesystem_ = filesystem; |
117 } | 113 } |
118 | 114 |
119 static FilesystemInterface *swap_default_filesystem( | 115 static FilesystemInterface *swap_default_filesystem( |
120 FilesystemInterface *filesystem) { | 116 FilesystemInterface *filesystem) { |
121 FilesystemInterface *cur = default_filesystem_; | 117 FilesystemInterface *cur = default_filesystem_; |
122 default_filesystem_ = filesystem; | 118 default_filesystem_ = filesystem; |
123 return cur; | 119 return cur; |
124 } | 120 } |
125 | 121 |
126 static bool CreateFolder(const Pathname &pathname) { | |
127 return EnsureDefaultFilesystem()->CreateFolder(pathname); | |
128 } | |
129 | |
130 static bool DeleteFile(const Pathname &filename) { | 122 static bool DeleteFile(const Pathname &filename) { |
131 return EnsureDefaultFilesystem()->DeleteFile(filename); | 123 return EnsureDefaultFilesystem()->DeleteFile(filename); |
132 } | 124 } |
133 | 125 |
134 static bool MoveFile(const Pathname &old_path, const Pathname &new_path) { | 126 static bool MoveFile(const Pathname &old_path, const Pathname &new_path) { |
135 return EnsureDefaultFilesystem()->MoveFile(old_path, new_path); | 127 return EnsureDefaultFilesystem()->MoveFile(old_path, new_path); |
136 } | 128 } |
137 | 129 |
138 static bool IsFolder(const Pathname& pathname) { | 130 static bool IsFolder(const Pathname& pathname) { |
139 return EnsureDefaultFilesystem()->IsFolder(pathname); | 131 return EnsureDefaultFilesystem()->IsFolder(pathname); |
(...skipping 15 matching lines...) Expand all Loading... |
155 private: | 147 private: |
156 static FilesystemInterface* default_filesystem_; | 148 static FilesystemInterface* default_filesystem_; |
157 | 149 |
158 static FilesystemInterface *EnsureDefaultFilesystem(); | 150 static FilesystemInterface *EnsureDefaultFilesystem(); |
159 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); | 151 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); |
160 }; | 152 }; |
161 | 153 |
162 } // namespace rtc | 154 } // namespace rtc |
163 | 155 |
164 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ | 156 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ |
OLD | NEW |