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 |
11 #ifndef WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ | 11 #ifndef WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ |
12 #define WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ | 12 #define WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ |
13 | 13 |
14 #include <sys/types.h> | 14 #include <sys/types.h> |
15 | 15 |
16 #include "webrtc/rtc_base/fileutils.h" | 16 #include "webrtc/rtc_base/fileutils.h" |
17 | 17 |
18 namespace rtc { | 18 namespace rtc { |
19 | 19 |
20 class UnixFilesystem : public FilesystemInterface { | 20 class UnixFilesystem : public FilesystemInterface { |
21 public: | 21 public: |
22 UnixFilesystem(); | 22 UnixFilesystem(); |
23 ~UnixFilesystem() override; | 23 ~UnixFilesystem() override; |
24 | 24 |
25 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC) | |
26 // Android does not have a native code API to fetch the app data or temp | |
27 // folders. That needs to be passed into this class from Java. Similarly, iOS | |
28 // only supports an Objective-C API for fetching the folder locations, so that | |
29 // needs to be passed in here from Objective-C. Or at least that used to be | |
30 // the case; now the ctor will do the work if necessary and possible. | |
31 // TODO(fischman): add an Android version that uses JNI and drop the | |
32 // SetApp*Folder() APIs once external users stop using them. | |
33 static void SetAppDataFolder(const std::string& folder); | |
34 static void SetAppTempFolder(const std::string& folder); | |
35 #endif | |
36 | |
37 // This will attempt to delete the file located at filename. | 25 // This will attempt to delete the file located at filename. |
38 // It will fail with VERIY if you pass it a non-existant file, or a directory. | 26 // It will fail with VERIY if you pass it a non-existant file, or a directory. |
39 bool DeleteFile(const Pathname& filename) override; | 27 bool DeleteFile(const Pathname& filename) override; |
40 | 28 |
41 // Creates a directory. This will call itself recursively to create /foo/bar | 29 // Creates a directory. This will call itself recursively to create /foo/bar |
42 // even if /foo does not exist. All created directories are created with the | 30 // even if /foo does not exist. All created directories are created with the |
43 // given mode. | 31 // given mode. |
44 // Returns TRUE if function succeeds | 32 // Returns TRUE if function succeeds |
45 virtual bool CreateFolder(const Pathname &pathname, mode_t mode); | 33 virtual bool CreateFolder(const Pathname &pathname, mode_t mode); |
46 | 34 |
(...skipping 11 matching lines...) Expand all Loading... |
58 // Returns true of pathname represents an existing file | 46 // Returns true of pathname represents an existing file |
59 bool IsFile(const Pathname& pathname) override; | 47 bool IsFile(const Pathname& pathname) override; |
60 | 48 |
61 // Returns true if pathname refers to no filesystem object, every parent | 49 // Returns true if pathname refers to no filesystem object, every parent |
62 // directory either exists, or is also absent. | 50 // directory either exists, or is also absent. |
63 bool IsAbsent(const Pathname& pathname) override; | 51 bool IsAbsent(const Pathname& pathname) override; |
64 | 52 |
65 std::string TempFilename(const Pathname& dir, | 53 std::string TempFilename(const Pathname& dir, |
66 const std::string& prefix) override; | 54 const std::string& prefix) override; |
67 | 55 |
68 // A folder appropriate for storing temporary files (Contents are | |
69 // automatically deleted when the program exists) | |
70 bool GetTemporaryFolder(Pathname& path, | |
71 bool create, | |
72 const std::string* append) override; | |
73 | |
74 bool GetFileSize(const Pathname& path, size_t* size) override; | 56 bool GetFileSize(const Pathname& path, size_t* size) override; |
75 | 57 |
76 private: | 58 private: |
77 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC) | 59 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC) |
78 static char* provided_app_data_folder_; | 60 static char* provided_app_data_folder_; |
79 static char* provided_app_temp_folder_; | 61 static char* provided_app_temp_folder_; |
80 #else | 62 #else |
81 static char* app_temp_path_; | 63 static char* app_temp_path_; |
82 #endif | 64 #endif |
83 | 65 |
84 static char* CopyString(const std::string& str); | 66 static char* CopyString(const std::string& str); |
85 }; | 67 }; |
86 | 68 |
87 } // namespace rtc | 69 } // namespace rtc |
88 | 70 |
89 #endif // WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ | 71 #endif // WEBRTC_RTC_BASE_UNIXFILESYSTEM_H_ |
OLD | NEW |