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_BASE_UNIXFILESYSTEM_H_ | 11 #ifndef WEBRTC_BASE_UNIXFILESYSTEM_H_ |
12 #define WEBRTC_BASE_UNIXFILESYSTEM_H_ | 12 #define WEBRTC_BASE_UNIXFILESYSTEM_H_ |
13 | 13 |
14 #include <sys/types.h> | |
15 | 14 |
16 #include "webrtc/base/fileutils.h" | 15 // This header is deprecated and is just left here temporarily during |
17 | 16 // refactoring. See https://bugs.webrtc.org/7634 for more details. |
18 namespace rtc { | 17 #include "webrtc/rtc_base/unixfilesystem.h" |
19 | |
20 class UnixFilesystem : public FilesystemInterface { | |
21 public: | |
22 UnixFilesystem(); | |
23 ~UnixFilesystem() override; | |
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. | |
38 // It will fail with VERIY if you pass it a non-existant file, or a directory. | |
39 bool DeleteFile(const Pathname& filename) override; | |
40 | |
41 // 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 | |
43 // given mode. | |
44 // Returns TRUE if function succeeds | |
45 virtual bool CreateFolder(const Pathname &pathname, mode_t mode); | |
46 | |
47 // As above, with mode = 0755. | |
48 bool CreateFolder(const Pathname& pathname) override; | |
49 | |
50 // This moves a file from old_path to new_path, where "file" can be a plain | |
51 // file or directory, which will be moved recursively. | |
52 // Returns true if function succeeds. | |
53 bool MoveFile(const Pathname& old_path, const Pathname& new_path) override; | |
54 | |
55 // Returns true if a pathname is a directory | |
56 bool IsFolder(const Pathname& pathname) override; | |
57 | |
58 // Returns true of pathname represents an existing file | |
59 bool IsFile(const Pathname& pathname) override; | |
60 | |
61 // Returns true if pathname refers to no filesystem object, every parent | |
62 // directory either exists, or is also absent. | |
63 bool IsAbsent(const Pathname& pathname) override; | |
64 | |
65 std::string TempFilename(const Pathname& dir, | |
66 const std::string& prefix) override; | |
67 | |
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; | |
75 | |
76 private: | |
77 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC) | |
78 static char* provided_app_data_folder_; | |
79 static char* provided_app_temp_folder_; | |
80 #else | |
81 static char* app_temp_path_; | |
82 #endif | |
83 | |
84 static char* CopyString(const std::string& str); | |
85 }; | |
86 | |
87 } // namespace rtc | |
88 | 18 |
89 #endif // WEBRTC_BASE_UNIXFILESYSTEM_H_ | 19 #endif // WEBRTC_BASE_UNIXFILESYSTEM_H_ |
OLD | NEW |