You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
5.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * libjingle
  3. * Copyright 2004--2006, Google Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  19. * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef _TALK_BASE_WIN32FILESYSTEM_H__
  28. #define _TALK_BASE_WIN32FILESYSTEM_H__
  29. #include "fileutils.h"
  30. namespace talk_base {
  31. class Win32Filesystem : public FilesystemInterface {
  32. public:
  33. // Opens a file. Returns an open StreamInterface if function succeeds. Otherwise,
  34. // returns NULL.
  35. virtual FileStream *OpenFile(const Pathname &filename,
  36. const std::string &mode);
  37. // Atomically creates an empty file accessible only to the current user if one
  38. // does not already exist at the given path, otherwise fails.
  39. virtual bool CreatePrivateFile(const Pathname &filename);
  40. // This will attempt to delete the path located at filename.
  41. // If the path points to a folder, it will fail with VERIFY
  42. virtual bool DeleteFile(const Pathname &filename);
  43. // This will attempt to delete an empty folder. If the path does not point to
  44. // a folder, it fails with VERIFY. If the folder is not empty, it fails normally
  45. virtual bool DeleteEmptyFolder(const Pathname &folder);
  46. // Creates a directory. This will call itself recursively to create /foo/bar even if
  47. // /foo does not exist.
  48. // Returns TRUE if function succeeds
  49. virtual bool CreateFolder(const Pathname &pathname);
  50. // This moves a file from old_path to new_path. If the new path is on a
  51. // different volume than the old, it will attempt to copy and then delete
  52. // the folder
  53. // Returns true if the file is successfully moved
  54. virtual bool MoveFile(const Pathname &old_path, const Pathname &new_path);
  55. // Moves a folder from old_path to new_path. If the new path is on a different
  56. // volume from the old, it will attempt to Copy and then Delete the folder
  57. // Returns true if the folder is successfully moved
  58. virtual bool MoveFolder(const Pathname &old_path, const Pathname &new_path);
  59. // This copies a file from old_path to _new_path
  60. // Returns true if function succeeds
  61. virtual bool CopyFile(const Pathname &old_path, const Pathname &new_path);
  62. // Returns true if a pathname is a directory
  63. virtual bool IsFolder(const Pathname& pathname);
  64. // Returns true if a file exists at path
  65. virtual bool IsFile(const Pathname &path);
  66. // Returns true if pathname refers to no filesystem object, every parent
  67. // directory either exists, or is also absent.
  68. virtual bool IsAbsent(const Pathname& pathname);
  69. // Returns true if pathname represents a temporary location on the system.
  70. virtual bool IsTemporaryPath(const Pathname& pathname);
  71. // All of the following functions set pathname and return true if successful.
  72. // Returned paths always include a trailing backslash.
  73. // If create is true, the path will be recursively created.
  74. // If append is non-NULL, it will be appended (and possibly created).
  75. virtual std::string TempFilename(const Pathname &dir, const std::string &prefix);
  76. virtual bool GetFileSize(const Pathname& path, size_t* size);
  77. virtual bool GetFileTime(const Pathname& path, FileTimeType which,
  78. time_t* time);
  79. // A folder appropriate for storing temporary files (Contents are
  80. // automatically deleted when the program exists)
  81. virtual bool GetTemporaryFolder(Pathname &path, bool create,
  82. const std::string *append);
  83. // Returns the path to the running application.
  84. virtual bool GetAppPathname(Pathname* path);
  85. virtual bool GetAppDataFolder(Pathname* path, bool per_user);
  86. // Get a temporary folder that is unique to the current user and application.
  87. virtual bool GetAppTempFolder(Pathname* path);
  88. virtual bool GetDiskFreeSpace(const Pathname& path, int64 *freebytes);
  89. virtual Pathname GetCurrentDirectory();
  90. };
  91. } // namespace talk_base
  92. #endif // _WIN32FILESYSTEM_H__