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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // plain file. This DCHECKs and returns false if old_path points to a | 91 // plain file. This DCHECKs and returns false if old_path points to a |
92 // directory, and returns true if the function succeeds. | 92 // directory, and returns true if the function succeeds. |
93 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0; | 93 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path) = 0; |
94 | 94 |
95 // Returns true if pathname refers to a directory | 95 // Returns true if pathname refers to a directory |
96 virtual bool IsFolder(const Pathname& pathname) = 0; | 96 virtual bool IsFolder(const Pathname& pathname) = 0; |
97 | 97 |
98 // Returns true if pathname refers to a file | 98 // Returns true if pathname refers to a file |
99 virtual bool IsFile(const Pathname& pathname) = 0; | 99 virtual bool IsFile(const Pathname& pathname) = 0; |
100 | 100 |
101 // Returns true if pathname refers to no filesystem object, every parent | |
102 // directory either exists, or is also absent. | |
103 virtual bool IsAbsent(const Pathname& pathname) = 0; | |
104 | |
105 virtual std::string TempFilename(const Pathname &dir, | 101 virtual std::string TempFilename(const Pathname &dir, |
106 const std::string &prefix) = 0; | 102 const std::string &prefix) = 0; |
107 | 103 |
108 // Determines the size of the file indicated by path. | 104 // Determines the size of the file indicated by path. |
109 virtual bool GetFileSize(const Pathname& path, size_t* size) = 0; | 105 virtual bool GetFileSize(const Pathname& path, size_t* size) = 0; |
110 }; | 106 }; |
111 | 107 |
112 class Filesystem { | 108 class Filesystem { |
113 public: | 109 public: |
114 static FilesystemInterface *default_filesystem() { | 110 static FilesystemInterface *default_filesystem() { |
(...skipping 25 matching lines...) Expand all Loading... |
140 } | 136 } |
141 | 137 |
142 static bool IsFolder(const Pathname& pathname) { | 138 static bool IsFolder(const Pathname& pathname) { |
143 return EnsureDefaultFilesystem()->IsFolder(pathname); | 139 return EnsureDefaultFilesystem()->IsFolder(pathname); |
144 } | 140 } |
145 | 141 |
146 static bool IsFile(const Pathname &pathname) { | 142 static bool IsFile(const Pathname &pathname) { |
147 return EnsureDefaultFilesystem()->IsFile(pathname); | 143 return EnsureDefaultFilesystem()->IsFile(pathname); |
148 } | 144 } |
149 | 145 |
150 static bool IsAbsent(const Pathname &pathname) { | |
151 return EnsureDefaultFilesystem()->IsAbsent(pathname); | |
152 } | |
153 | |
154 static std::string TempFilename(const Pathname &dir, | 146 static std::string TempFilename(const Pathname &dir, |
155 const std::string &prefix) { | 147 const std::string &prefix) { |
156 return EnsureDefaultFilesystem()->TempFilename(dir, prefix); | 148 return EnsureDefaultFilesystem()->TempFilename(dir, prefix); |
157 } | 149 } |
158 | 150 |
159 static bool GetFileSize(const Pathname& path, size_t* size) { | 151 static bool GetFileSize(const Pathname& path, size_t* size) { |
160 return EnsureDefaultFilesystem()->GetFileSize(path, size); | 152 return EnsureDefaultFilesystem()->GetFileSize(path, size); |
161 } | 153 } |
162 | 154 |
163 private: | 155 private: |
164 static FilesystemInterface* default_filesystem_; | 156 static FilesystemInterface* default_filesystem_; |
165 | 157 |
166 static FilesystemInterface *EnsureDefaultFilesystem(); | 158 static FilesystemInterface *EnsureDefaultFilesystem(); |
167 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); | 159 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); |
168 }; | 160 }; |
169 | 161 |
170 } // namespace rtc | 162 } // namespace rtc |
171 | 163 |
172 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ | 164 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ |
OLD | NEW |