oculus1
view libovr/Src/Kernel/OVR_SysFile.h @ 10:b2abb08c8f94
proper FPS-style vr tracking
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 20 Sep 2013 06:49:39 +0300 |
parents | e2f9e4603129 |
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 2012 Oculus VR, Inc. All Rights reserved.
16 Use of this software is subject to the terms of the Oculus license
17 agreement provided at the time of installation or download, or which
18 otherwise accompanies this software in either electronic or hard copy form.
20 ************************************************************************************/
22 #ifndef OVR_SysFile_h
23 #define OVR_SysFile_h
25 #include "OVR_File.h"
27 namespace OVR {
29 // ***** Declared classes
30 class SysFile;
32 //-----------------------------------------------------------------------------------
33 // *** File Statistics
35 // This class contents are similar to _stat, providing
36 // creation, modify and other information about the file.
37 struct FileStat
38 {
39 // No change or create time because they are not available on most systems
40 SInt64 ModifyTime;
41 SInt64 AccessTime;
42 SInt64 FileSize;
44 bool operator== (const FileStat& stat) const
45 {
46 return ( (ModifyTime == stat.ModifyTime) &&
47 (AccessTime == stat.AccessTime) &&
48 (FileSize == stat.FileSize) );
49 }
50 };
52 //-----------------------------------------------------------------------------------
53 // *** System File
55 // System file is created to access objects on file system directly
56 // This file can refer directly to path.
57 // System file can be open & closed several times; however, such use is not recommended
58 // This class is realy a wrapper around an implementation of File interface for a
59 // particular platform.
61 class SysFile : public DelegatedFile
62 {
63 protected:
64 SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); }
65 public:
67 // ** Constructor
68 SysFile();
69 // Opens a file
70 SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
72 // ** Open & management
73 bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
75 OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
76 { return Open(path, Open_ReadWrite|Open_Create, mode); }
78 // Helper function: obtain file statistics information. In GFx, this is used to detect file changes.
79 // Return 0 if function failed, most likely because the file doesn't exist.
80 static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path);
82 // ** Overrides
83 // Overridden to provide re-open support
84 virtual int GetErrorCode();
86 virtual bool IsValid();
88 virtual bool Close();
89 };
91 } // Scaleform
93 #endif