ovr_sdk

view LibOVR/Src/Kernel/OVR_SysFile.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
line source
1 /************************************************************************************
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 :
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)
14 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
16 Licensed under the Oculus VR Rift SDK License Version 3.2 (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.
21 You may obtain a copy of the License at
23 http://www.oculusvr.com/licenses/LICENSE-3.2
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.
31 ************************************************************************************/
33 #ifndef OVR_SysFile_h
34 #define OVR_SysFile_h
36 #include "OVR_File.h"
38 namespace OVR {
40 // ***** Declared classes
41 class SysFile;
43 //-----------------------------------------------------------------------------------
44 // *** File Statistics
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
51 int64_t ModifyTime;
52 int64_t AccessTime;
53 int64_t FileSize;
55 bool operator== (const FileStat& stat) const
56 {
57 return ( (ModifyTime == stat.ModifyTime) &&
58 (AccessTime == stat.AccessTime) &&
59 (FileSize == stat.FileSize) );
60 }
61 };
63 //-----------------------------------------------------------------------------------
64 // *** System File
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.
72 class SysFile : public DelegatedFile
73 {
74 protected:
75 SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); }
76 public:
78 // ** Constructor
79 SysFile();
80 // Opens a file
81 SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
83 // ** Open & management
84 bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
86 OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
87 { return Open(path, Open_ReadWrite|Open_Create, mode); }
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);
93 // ** Overrides
94 // Overridden to provide re-open support
95 virtual int GetErrorCode();
97 virtual bool IsValid();
99 virtual bool Close();
100 };
102 } // Namespace OVR
104 #endif