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