blob: dd3caed385e0f5996e7291df5fbd546b568671ef [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001/*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef _WEBRTC_BASE_WIN32FILESYSTEM_H__
12#define _WEBRTC_BASE_WIN32FILESYSTEM_H__
13
14#include "fileutils.h"
15
16namespace rtc {
17
18class Win32Filesystem : public FilesystemInterface {
19 public:
20 // Opens a file. Returns an open StreamInterface if function succeeds. Otherwise,
21 // returns NULL.
22 virtual FileStream *OpenFile(const Pathname &filename,
23 const std::string &mode);
24
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000025 // This will attempt to delete the path located at filename.
26 // If the path points to a folder, it will fail with VERIFY
27 virtual bool DeleteFile(const Pathname &filename);
28
29 // This will attempt to delete an empty folder. If the path does not point to
30 // a folder, it fails with VERIFY. If the folder is not empty, it fails normally
31 virtual bool DeleteEmptyFolder(const Pathname &folder);
32
33 // Creates a directory. This will call itself recursively to create /foo/bar even if
34 // /foo does not exist.
35 // Returns TRUE if function succeeds
36 virtual bool CreateFolder(const Pathname &pathname);
37
38 // This moves a file from old_path to new_path. If the new path is on a
39 // different volume than the old, it will attempt to copy and then delete
40 // the folder
41 // Returns true if the file is successfully moved
42 virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path);
43
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000044 // This copies a file from old_path to _new_path
45 // Returns true if function succeeds
46 virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path);
47
48 // Returns true if a pathname is a directory
49 virtual bool IsFolder(const Pathname& pathname);
50
51 // Returns true if a file exists at path
52 virtual bool IsFile(const Pathname &path);
53
54 // Returns true if pathname refers to no filesystem object, every parent
55 // directory either exists, or is also absent.
56 virtual bool IsAbsent(const Pathname& pathname);
57
58 // Returns true if pathname represents a temporary location on the system.
59 virtual bool IsTemporaryPath(const Pathname& pathname);
60
61 // All of the following functions set pathname and return true if successful.
62 // Returned paths always include a trailing backslash.
63 // If create is true, the path will be recursively created.
64 // If append is non-NULL, it will be appended (and possibly created).
65
66 virtual std::string TempFilename(const Pathname &dir, const std::string &prefix);
67
68 virtual bool GetFileSize(const Pathname& path, size_t* size);
69 virtual bool GetFileTime(const Pathname& path, FileTimeType which,
70 time_t* time);
nisseda35f3e2016-10-27 04:44:39 -070071
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000072 // A folder appropriate for storing temporary files (Contents are
73 // automatically deleted when the program exists)
74 virtual bool GetTemporaryFolder(Pathname &path, bool create,
75 const std::string *append);
76
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000077 // Get a temporary folder that is unique to the current user and application.
78 virtual bool GetAppTempFolder(Pathname* path);
79
nisseda35f3e2016-10-27 04:44:39 -070080 private:
81 // Returns the path to the running application.
82 bool GetAppPathname(Pathname* path);
henrike@webrtc.orgf0488722014-05-13 18:00:26 +000083};
84
85} // namespace rtc
86
87#endif // WEBRTC_WINFILESYSTEM_H__