nuclear@0: /************************************************************************************ nuclear@0: nuclear@0: PublicHeader: Kernel nuclear@0: Filename : OVR_SysFile.h nuclear@0: Content : Header for all internal file management - functions and structures nuclear@0: to be inherited by OS specific subclasses. nuclear@0: Created : September 19, 2012 nuclear@0: Notes : nuclear@0: nuclear@0: Notes : errno may not be preserved across use of GBaseFile member functions nuclear@0: : Directories cannot be deleted while files opened from them are in use nuclear@0: (For the GetFullName function) nuclear@0: nuclear@0: Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. nuclear@0: nuclear@0: Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); nuclear@0: you may not use the Oculus VR Rift SDK except in compliance with the License, nuclear@0: which is provided at the time of installation or download, or which nuclear@0: otherwise accompanies this software in either electronic or hard copy form. nuclear@0: nuclear@0: You may obtain a copy of the License at nuclear@0: nuclear@0: http://www.oculusvr.com/licenses/LICENSE-3.2 nuclear@0: nuclear@0: Unless required by applicable law or agreed to in writing, the Oculus VR SDK nuclear@0: distributed under the License is distributed on an "AS IS" BASIS, nuclear@0: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. nuclear@0: See the License for the specific language governing permissions and nuclear@0: limitations under the License. nuclear@0: nuclear@0: ************************************************************************************/ nuclear@0: nuclear@0: #ifndef OVR_SysFile_h nuclear@0: #define OVR_SysFile_h nuclear@0: nuclear@0: #include "OVR_File.h" nuclear@0: nuclear@0: namespace OVR { nuclear@0: nuclear@0: // ***** Declared classes nuclear@0: class SysFile; nuclear@0: nuclear@0: //----------------------------------------------------------------------------------- nuclear@0: // *** File Statistics nuclear@0: nuclear@0: // This class contents are similar to _stat, providing nuclear@0: // creation, modify and other information about the file. nuclear@0: struct FileStat nuclear@0: { nuclear@0: // No change or create time because they are not available on most systems nuclear@0: int64_t ModifyTime; nuclear@0: int64_t AccessTime; nuclear@0: int64_t FileSize; nuclear@0: nuclear@0: bool operator== (const FileStat& stat) const nuclear@0: { nuclear@0: return ( (ModifyTime == stat.ModifyTime) && nuclear@0: (AccessTime == stat.AccessTime) && nuclear@0: (FileSize == stat.FileSize) ); nuclear@0: } nuclear@0: }; nuclear@0: nuclear@0: //----------------------------------------------------------------------------------- nuclear@0: // *** System File nuclear@0: nuclear@0: // System file is created to access objects on file system directly nuclear@0: // This file can refer directly to path. nuclear@0: // System file can be open & closed several times; however, such use is not recommended nuclear@0: // This class is realy a wrapper around an implementation of File interface for a nuclear@0: // particular platform. nuclear@0: nuclear@0: class SysFile : public DelegatedFile nuclear@0: { nuclear@0: protected: nuclear@0: SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); } nuclear@0: public: nuclear@0: nuclear@0: // ** Constructor nuclear@0: SysFile(); nuclear@0: // Opens a file nuclear@0: SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); nuclear@0: nuclear@0: // ** Open & management nuclear@0: bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); nuclear@0: nuclear@0: OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite) nuclear@0: { return Open(path, Open_ReadWrite|Open_Create, mode); } nuclear@0: nuclear@0: // Helper function: obtain file statistics information. In OVR, this is used to detect file changes. nuclear@0: // Return 0 if function failed, most likely because the file doesn't exist. nuclear@0: static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path); nuclear@0: nuclear@0: // ** Overrides nuclear@0: // Overridden to provide re-open support nuclear@0: virtual int GetErrorCode(); nuclear@0: nuclear@0: virtual bool IsValid(); nuclear@0: nuclear@0: virtual bool Close(); nuclear@0: }; nuclear@0: nuclear@0: } // Namespace OVR nuclear@0: nuclear@0: #endif