• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
16 namespace rtc {
17 
18 class 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 
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.
30   // If the path points to a folder, it will fail with VERIFY
31   virtual bool DeleteFile(const Pathname &filename);
32 
33   // 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 normally
35   virtual bool DeleteEmptyFolder(const Pathname &folder);
36 
37   // Creates a directory. This will call itself recursively to create /foo/bar even if
38   // /foo does not exist.
39   // Returns TRUE if function succeeds
40   virtual bool CreateFolder(const Pathname &pathname);
41 
42   // 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
44   // the folder
45   // Returns true if the file is successfully moved
46   virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path);
47 
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
54   // Returns true if function succeeds
55   virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path);
56 
57   // Returns true if a pathname is a directory
58   virtual bool IsFolder(const Pathname& pathname);
59 
60   // Returns true if a file exists at path
61   virtual bool IsFile(const Pathname &path);
62 
63   // Returns true if pathname refers to no filesystem object, every parent
64   // directory either exists, or is also absent.
65   virtual bool IsAbsent(const Pathname& pathname);
66 
67   // Returns true if pathname represents a temporary location on the system.
68   virtual bool IsTemporaryPath(const Pathname& pathname);
69 
70   // All of the following functions set pathname and return true if successful.
71   // Returned paths always include a trailing backslash.
72   // If create is true, the path will be recursively created.
73   // If append is non-NULL, it will be appended (and possibly created).
74 
75   virtual std::string TempFilename(const Pathname &dir, const std::string &prefix);
76 
77   virtual bool GetFileSize(const Pathname& path, size_t* size);
78   virtual bool GetFileTime(const Pathname& path, FileTimeType which,
79                            time_t* time);
80 
81   // A folder appropriate for storing temporary files (Contents are
82   // automatically deleted when the program exists)
83   virtual bool GetTemporaryFolder(Pathname &path, bool create,
84                                  const std::string *append);
85 
86   // Returns the path to the running application.
87   virtual bool GetAppPathname(Pathname* path);
88 
89   virtual bool GetAppDataFolder(Pathname* path, bool per_user);
90 
91   // Get a temporary folder that is unique to the current user and application.
92   virtual bool GetAppTempFolder(Pathname* path);
93 
94   virtual bool GetDiskFreeSpace(const Pathname& path, int64_t* free_bytes);
95 
96   virtual Pathname GetCurrentDirectory();
97 };
98 
99 }  // namespace rtc
100 
101 #endif  // WEBRTC_WINFILESYSTEM_H__
102