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_WIN32FILESYSTEM_H__ | 11 #ifndef _WEBRTC_BASE_WIN32FILESYSTEM_H__ |
12 #define _WEBRTC_BASE_WIN32FILESYSTEM_H__ | 12 #define _WEBRTC_BASE_WIN32FILESYSTEM_H__ |
13 | 13 |
14 #include "fileutils.h" | 14 #include "fileutils.h" |
15 | 15 |
16 namespace rtc { | 16 namespace rtc { |
17 | 17 |
18 class Win32Filesystem : public FilesystemInterface { | 18 class Win32Filesystem : public FilesystemInterface { |
19 public: | 19 public: |
20 // Opens a file. Returns an open StreamInterface if function succeeds. Otherwi
se, | 20 // Opens a file. Returns an open StreamInterface if function succeeds. Otherwi
se, |
21 // returns NULL. | 21 // returns NULL. |
22 virtual FileStream *OpenFile(const Pathname &filename, | 22 virtual FileStream *OpenFile(const Pathname &filename, |
23 const std::string &mode); | 23 const std::string &mode); |
24 | 24 |
25 // Atomically creates an empty file accessible only to the current user if one | |
26 // does not already exist at the given path, otherwise fails. | |
27 virtual bool CreatePrivateFile(const Pathname &filename); | |
28 | |
29 // This will attempt to delete the path located at filename. | 25 // This will attempt to delete the path located at filename. |
30 // If the path points to a folder, it will fail with VERIFY | 26 // If the path points to a folder, it will fail with VERIFY |
31 virtual bool DeleteFile(const Pathname &filename); | 27 virtual bool DeleteFile(const Pathname &filename); |
32 | 28 |
33 // This will attempt to delete an empty folder. If the path does not point to | 29 // This will attempt to delete an empty folder. If the path does not point to |
34 // a folder, it fails with VERIFY. If the folder is not empty, it fails normal
ly | 30 // a folder, it fails with VERIFY. If the folder is not empty, it fails normal
ly |
35 virtual bool DeleteEmptyFolder(const Pathname &folder); | 31 virtual bool DeleteEmptyFolder(const Pathname &folder); |
36 | 32 |
37 // Creates a directory. This will call itself recursively to create /foo/bar e
ven if | 33 // Creates a directory. This will call itself recursively to create /foo/bar e
ven if |
38 // /foo does not exist. | 34 // /foo does not exist. |
39 // Returns TRUE if function succeeds | 35 // Returns TRUE if function succeeds |
40 virtual bool CreateFolder(const Pathname &pathname); | 36 virtual bool CreateFolder(const Pathname &pathname); |
41 | 37 |
42 // This moves a file from old_path to new_path. If the new path is on a | 38 // This moves a file from old_path to new_path. If the new path is on a |
43 // different volume than the old, it will attempt to copy and then delete | 39 // different volume than the old, it will attempt to copy and then delete |
44 // the folder | 40 // the folder |
45 // Returns true if the file is successfully moved | 41 // Returns true if the file is successfully moved |
46 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path); | 42 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path); |
47 | 43 |
48 // Moves a folder from old_path to new_path. If the new path is on a different | |
49 // volume from the old, it will attempt to Copy and then Delete the folder | |
50 // Returns true if the folder is successfully moved | |
51 virtual bool MoveFolder(const Pathname &old_path, const Pathname &new_path); | |
52 | |
53 // This copies a file from old_path to _new_path | 44 // This copies a file from old_path to _new_path |
54 // Returns true if function succeeds | 45 // Returns true if function succeeds |
55 virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path); | 46 virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path); |
56 | 47 |
57 // Returns true if a pathname is a directory | 48 // Returns true if a pathname is a directory |
58 virtual bool IsFolder(const Pathname& pathname); | 49 virtual bool IsFolder(const Pathname& pathname); |
59 | 50 |
60 // Returns true if a file exists at path | 51 // Returns true if a file exists at path |
61 virtual bool IsFile(const Pathname &path); | 52 virtual bool IsFile(const Pathname &path); |
62 | 53 |
63 // Returns true if pathname refers to no filesystem object, every parent | 54 // Returns true if pathname refers to no filesystem object, every parent |
64 // directory either exists, or is also absent. | 55 // directory either exists, or is also absent. |
65 virtual bool IsAbsent(const Pathname& pathname); | 56 virtual bool IsAbsent(const Pathname& pathname); |
66 | 57 |
67 // Returns true if pathname represents a temporary location on the system. | 58 // Returns true if pathname represents a temporary location on the system. |
68 virtual bool IsTemporaryPath(const Pathname& pathname); | 59 virtual bool IsTemporaryPath(const Pathname& pathname); |
69 | 60 |
70 // All of the following functions set pathname and return true if successful. | 61 // All of the following functions set pathname and return true if successful. |
71 // Returned paths always include a trailing backslash. | 62 // Returned paths always include a trailing backslash. |
72 // If create is true, the path will be recursively created. | 63 // If create is true, the path will be recursively created. |
73 // If append is non-NULL, it will be appended (and possibly created). | 64 // If append is non-NULL, it will be appended (and possibly created). |
74 | 65 |
75 virtual std::string TempFilename(const Pathname &dir, const std::string &prefi
x); | 66 virtual std::string TempFilename(const Pathname &dir, const std::string &prefi
x); |
76 | 67 |
77 virtual bool GetFileSize(const Pathname& path, size_t* size); | 68 virtual bool GetFileSize(const Pathname& path, size_t* size); |
78 virtual bool GetFileTime(const Pathname& path, FileTimeType which, | 69 virtual bool GetFileTime(const Pathname& path, FileTimeType which, |
79 time_t* time); | 70 time_t* time); |
80 | 71 |
81 // A folder appropriate for storing temporary files (Contents are | 72 // A folder appropriate for storing temporary files (Contents are |
82 // automatically deleted when the program exists) | 73 // automatically deleted when the program exists) |
83 virtual bool GetTemporaryFolder(Pathname &path, bool create, | 74 virtual bool GetTemporaryFolder(Pathname &path, bool create, |
84 const std::string *append); | 75 const std::string *append); |
85 | 76 |
86 // Returns the path to the running application. | |
87 virtual bool GetAppPathname(Pathname* path); | |
88 | |
89 virtual bool GetAppDataFolder(Pathname* path, bool per_user); | 77 virtual bool GetAppDataFolder(Pathname* path, bool per_user); |
90 | 78 |
91 // Get a temporary folder that is unique to the current user and application. | 79 // Get a temporary folder that is unique to the current user and application. |
92 virtual bool GetAppTempFolder(Pathname* path); | 80 virtual bool GetAppTempFolder(Pathname* path); |
93 | 81 |
94 virtual bool GetDiskFreeSpace(const Pathname& path, int64_t* free_bytes); | 82 virtual bool GetDiskFreeSpace(const Pathname& path, int64_t* free_bytes); |
95 | 83 |
96 virtual Pathname GetCurrentDirectory(); | 84 private: |
| 85 // Returns the path to the running application. |
| 86 bool GetAppPathname(Pathname* path); |
97 }; | 87 }; |
98 | 88 |
99 } // namespace rtc | 89 } // namespace rtc |
100 | 90 |
101 #endif // WEBRTC_WINFILESYSTEM_H__ | 91 #endif // WEBRTC_WINFILESYSTEM_H__ |
OLD | NEW |