ovr_sdk
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/LibOVR/Src/Kernel/OVR_SysFile.h Wed Jan 14 06:51:16 2015 +0200 1.3 @@ -0,0 +1,104 @@ 1.4 +/************************************************************************************ 1.5 + 1.6 +PublicHeader: Kernel 1.7 +Filename : OVR_SysFile.h 1.8 +Content : Header for all internal file management - functions and structures 1.9 + to be inherited by OS specific subclasses. 1.10 +Created : September 19, 2012 1.11 +Notes : 1.12 + 1.13 +Notes : errno may not be preserved across use of GBaseFile member functions 1.14 + : Directories cannot be deleted while files opened from them are in use 1.15 + (For the GetFullName function) 1.16 + 1.17 +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. 1.18 + 1.19 +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); 1.20 +you may not use the Oculus VR Rift SDK except in compliance with the License, 1.21 +which is provided at the time of installation or download, or which 1.22 +otherwise accompanies this software in either electronic or hard copy form. 1.23 + 1.24 +You may obtain a copy of the License at 1.25 + 1.26 +http://www.oculusvr.com/licenses/LICENSE-3.2 1.27 + 1.28 +Unless required by applicable law or agreed to in writing, the Oculus VR SDK 1.29 +distributed under the License is distributed on an "AS IS" BASIS, 1.30 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.31 +See the License for the specific language governing permissions and 1.32 +limitations under the License. 1.33 + 1.34 +************************************************************************************/ 1.35 + 1.36 +#ifndef OVR_SysFile_h 1.37 +#define OVR_SysFile_h 1.38 + 1.39 +#include "OVR_File.h" 1.40 + 1.41 +namespace OVR { 1.42 + 1.43 +// ***** Declared classes 1.44 +class SysFile; 1.45 + 1.46 +//----------------------------------------------------------------------------------- 1.47 +// *** File Statistics 1.48 + 1.49 +// This class contents are similar to _stat, providing 1.50 +// creation, modify and other information about the file. 1.51 +struct FileStat 1.52 +{ 1.53 + // No change or create time because they are not available on most systems 1.54 + int64_t ModifyTime; 1.55 + int64_t AccessTime; 1.56 + int64_t FileSize; 1.57 + 1.58 + bool operator== (const FileStat& stat) const 1.59 + { 1.60 + return ( (ModifyTime == stat.ModifyTime) && 1.61 + (AccessTime == stat.AccessTime) && 1.62 + (FileSize == stat.FileSize) ); 1.63 + } 1.64 +}; 1.65 + 1.66 +//----------------------------------------------------------------------------------- 1.67 +// *** System File 1.68 + 1.69 +// System file is created to access objects on file system directly 1.70 +// This file can refer directly to path. 1.71 +// System file can be open & closed several times; however, such use is not recommended 1.72 +// This class is realy a wrapper around an implementation of File interface for a 1.73 +// particular platform. 1.74 + 1.75 +class SysFile : public DelegatedFile 1.76 +{ 1.77 +protected: 1.78 + SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); } 1.79 +public: 1.80 + 1.81 + // ** Constructor 1.82 + SysFile(); 1.83 + // Opens a file 1.84 + SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); 1.85 + 1.86 + // ** Open & management 1.87 + bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); 1.88 + 1.89 + OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite) 1.90 + { return Open(path, Open_ReadWrite|Open_Create, mode); } 1.91 + 1.92 + // Helper function: obtain file statistics information. In OVR, this is used to detect file changes. 1.93 + // Return 0 if function failed, most likely because the file doesn't exist. 1.94 + static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path); 1.95 + 1.96 + // ** Overrides 1.97 + // Overridden to provide re-open support 1.98 + virtual int GetErrorCode(); 1.99 + 1.100 + virtual bool IsValid(); 1.101 + 1.102 + virtual bool Close(); 1.103 +}; 1.104 + 1.105 +} // Namespace OVR 1.106 + 1.107 +#endif