oculus1

annotate libovr/Src/Kernel/OVR_SysFile.h @ 12:d797639e0234

moving on to the distortion... not correct yet
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 20 Sep 2013 10:14:29 +0300
parents e2f9e4603129
children
rev   line source
nuclear@3 1 /************************************************************************************
nuclear@3 2
nuclear@3 3 PublicHeader: Kernel
nuclear@3 4 Filename : OVR_SysFile.h
nuclear@3 5 Content : Header for all internal file management - functions and structures
nuclear@3 6 to be inherited by OS specific subclasses.
nuclear@3 7 Created : September 19, 2012
nuclear@3 8 Notes :
nuclear@3 9
nuclear@3 10 Notes : errno may not be preserved across use of GBaseFile member functions
nuclear@3 11 : Directories cannot be deleted while files opened from them are in use
nuclear@3 12 (For the GetFullName function)
nuclear@3 13
nuclear@3 14 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
nuclear@3 15
nuclear@3 16 Use of this software is subject to the terms of the Oculus license
nuclear@3 17 agreement provided at the time of installation or download, or which
nuclear@3 18 otherwise accompanies this software in either electronic or hard copy form.
nuclear@3 19
nuclear@3 20 ************************************************************************************/
nuclear@3 21
nuclear@3 22 #ifndef OVR_SysFile_h
nuclear@3 23 #define OVR_SysFile_h
nuclear@3 24
nuclear@3 25 #include "OVR_File.h"
nuclear@3 26
nuclear@3 27 namespace OVR {
nuclear@3 28
nuclear@3 29 // ***** Declared classes
nuclear@3 30 class SysFile;
nuclear@3 31
nuclear@3 32 //-----------------------------------------------------------------------------------
nuclear@3 33 // *** File Statistics
nuclear@3 34
nuclear@3 35 // This class contents are similar to _stat, providing
nuclear@3 36 // creation, modify and other information about the file.
nuclear@3 37 struct FileStat
nuclear@3 38 {
nuclear@3 39 // No change or create time because they are not available on most systems
nuclear@3 40 SInt64 ModifyTime;
nuclear@3 41 SInt64 AccessTime;
nuclear@3 42 SInt64 FileSize;
nuclear@3 43
nuclear@3 44 bool operator== (const FileStat& stat) const
nuclear@3 45 {
nuclear@3 46 return ( (ModifyTime == stat.ModifyTime) &&
nuclear@3 47 (AccessTime == stat.AccessTime) &&
nuclear@3 48 (FileSize == stat.FileSize) );
nuclear@3 49 }
nuclear@3 50 };
nuclear@3 51
nuclear@3 52 //-----------------------------------------------------------------------------------
nuclear@3 53 // *** System File
nuclear@3 54
nuclear@3 55 // System file is created to access objects on file system directly
nuclear@3 56 // This file can refer directly to path.
nuclear@3 57 // System file can be open & closed several times; however, such use is not recommended
nuclear@3 58 // This class is realy a wrapper around an implementation of File interface for a
nuclear@3 59 // particular platform.
nuclear@3 60
nuclear@3 61 class SysFile : public DelegatedFile
nuclear@3 62 {
nuclear@3 63 protected:
nuclear@3 64 SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); }
nuclear@3 65 public:
nuclear@3 66
nuclear@3 67 // ** Constructor
nuclear@3 68 SysFile();
nuclear@3 69 // Opens a file
nuclear@3 70 SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
nuclear@3 71
nuclear@3 72 // ** Open & management
nuclear@3 73 bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
nuclear@3 74
nuclear@3 75 OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
nuclear@3 76 { return Open(path, Open_ReadWrite|Open_Create, mode); }
nuclear@3 77
nuclear@3 78 // Helper function: obtain file statistics information. In GFx, this is used to detect file changes.
nuclear@3 79 // Return 0 if function failed, most likely because the file doesn't exist.
nuclear@3 80 static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path);
nuclear@3 81
nuclear@3 82 // ** Overrides
nuclear@3 83 // Overridden to provide re-open support
nuclear@3 84 virtual int GetErrorCode();
nuclear@3 85
nuclear@3 86 virtual bool IsValid();
nuclear@3 87
nuclear@3 88 virtual bool Close();
nuclear@3 89 };
nuclear@3 90
nuclear@3 91 } // Scaleform
nuclear@3 92
nuclear@3 93 #endif