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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 101 // Returns true if pathname refers to no filesystem object, every parent |
102 // directory either exists, or is also absent. | 102 // directory either exists, or is also absent. |
103 virtual bool IsAbsent(const Pathname& pathname) = 0; | 103 virtual bool IsAbsent(const Pathname& pathname) = 0; |
104 | 104 |
105 // A folder appropriate for storing temporary files (Contents are | |
106 // automatically deleted when the program exits) | |
107 virtual bool GetTemporaryFolder(Pathname &path, bool create, | |
108 const std::string *append) = 0; | |
109 | |
110 virtual std::string TempFilename(const Pathname &dir, | 105 virtual std::string TempFilename(const Pathname &dir, |
111 const std::string &prefix) = 0; | 106 const std::string &prefix) = 0; |
112 | 107 |
113 // Determines the size of the file indicated by path. | 108 // Determines the size of the file indicated by path. |
114 virtual bool GetFileSize(const Pathname& path, size_t* size) = 0; | 109 virtual bool GetFileSize(const Pathname& path, size_t* size) = 0; |
115 }; | 110 }; |
116 | 111 |
117 class Filesystem { | 112 class Filesystem { |
118 public: | 113 public: |
119 static FilesystemInterface *default_filesystem() { | 114 static FilesystemInterface *default_filesystem() { |
(...skipping 29 matching lines...) Expand all Loading... |
149 } | 144 } |
150 | 145 |
151 static bool IsFile(const Pathname &pathname) { | 146 static bool IsFile(const Pathname &pathname) { |
152 return EnsureDefaultFilesystem()->IsFile(pathname); | 147 return EnsureDefaultFilesystem()->IsFile(pathname); |
153 } | 148 } |
154 | 149 |
155 static bool IsAbsent(const Pathname &pathname) { | 150 static bool IsAbsent(const Pathname &pathname) { |
156 return EnsureDefaultFilesystem()->IsAbsent(pathname); | 151 return EnsureDefaultFilesystem()->IsAbsent(pathname); |
157 } | 152 } |
158 | 153 |
159 static bool GetTemporaryFolder(Pathname &path, bool create, | |
160 const std::string *append) { | |
161 return EnsureDefaultFilesystem()->GetTemporaryFolder(path, create, append); | |
162 } | |
163 | |
164 static std::string TempFilename(const Pathname &dir, | 154 static std::string TempFilename(const Pathname &dir, |
165 const std::string &prefix) { | 155 const std::string &prefix) { |
166 return EnsureDefaultFilesystem()->TempFilename(dir, prefix); | 156 return EnsureDefaultFilesystem()->TempFilename(dir, prefix); |
167 } | 157 } |
168 | 158 |
169 static bool GetFileSize(const Pathname& path, size_t* size) { | 159 static bool GetFileSize(const Pathname& path, size_t* size) { |
170 return EnsureDefaultFilesystem()->GetFileSize(path, size); | 160 return EnsureDefaultFilesystem()->GetFileSize(path, size); |
171 } | 161 } |
172 | 162 |
173 private: | 163 private: |
174 static FilesystemInterface* default_filesystem_; | 164 static FilesystemInterface* default_filesystem_; |
175 | 165 |
176 static FilesystemInterface *EnsureDefaultFilesystem(); | 166 static FilesystemInterface *EnsureDefaultFilesystem(); |
177 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); | 167 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Filesystem); |
178 }; | 168 }; |
179 | 169 |
180 } // namespace rtc | 170 } // namespace rtc |
181 | 171 |
182 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ | 172 #endif // WEBRTC_RTC_BASE_FILEUTILS_H_ |
OLD | NEW |