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