OVR_SysFile.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /************************************************************************************
  2. PublicHeader: Kernel
  3. Filename : OVR_SysFile.h
  4. Content : Header for all internal file management - functions and structures
  5. to be inherited by OS specific subclasses.
  6. Created : September 19, 2012
  7. Notes :
  8. Notes : errno may not be preserved across use of GBaseFile member functions
  9. : Directories cannot be deleted while files opened from them are in use
  10. (For the GetFullName function)
  11. Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
  12. Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
  13. you may not use the Oculus VR Rift SDK except in compliance with the License,
  14. which is provided at the time of installation or download, or which
  15. otherwise accompanies this software in either electronic or hard copy form.
  16. You may obtain a copy of the License at
  17. http://www.oculusvr.com/licenses/LICENSE-3.2
  18. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  19. distributed under the License is distributed on an "AS IS" BASIS,
  20. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. See the License for the specific language governing permissions and
  22. limitations under the License.
  23. ************************************************************************************/
  24. #ifndef OVR_SysFile_h
  25. #define OVR_SysFile_h
  26. #include "OVR_File.h"
  27. namespace OVR {
  28. // ***** Declared classes
  29. class SysFile;
  30. //-----------------------------------------------------------------------------------
  31. // *** File Statistics
  32. // This class contents are similar to _stat, providing
  33. // creation, modify and other information about the file.
  34. struct FileStat
  35. {
  36. // No change or create time because they are not available on most systems
  37. int64_t ModifyTime;
  38. int64_t AccessTime;
  39. int64_t FileSize;
  40. bool operator== (const FileStat& stat) const
  41. {
  42. return ( (ModifyTime == stat.ModifyTime) &&
  43. (AccessTime == stat.AccessTime) &&
  44. (FileSize == stat.FileSize) );
  45. }
  46. };
  47. //-----------------------------------------------------------------------------------
  48. // *** System File
  49. // System file is created to access objects on file system directly
  50. // This file can refer directly to path.
  51. // System file can be open & closed several times; however, such use is not recommended
  52. // This class is realy a wrapper around an implementation of File interface for a
  53. // particular platform.
  54. class SysFile : public DelegatedFile
  55. {
  56. protected:
  57. SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); }
  58. public:
  59. // ** Constructor
  60. SysFile();
  61. // Opens a file
  62. SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
  63. // ** Open & management
  64. bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
  65. OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
  66. { return Open(path, Open_ReadWrite|Open_Create, mode); }
  67. // Helper function: obtain file statistics information. In OVR, this is used to detect file changes.
  68. // Return 0 if function failed, most likely because the file doesn't exist.
  69. static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path);
  70. // ** Overrides
  71. // Overridden to provide re-open support
  72. virtual int GetErrorCode();
  73. virtual bool IsValid();
  74. virtual bool Close();
  75. };
  76. } // Namespace OVR
  77. #endif