oculus1

annotate libovr/Src/Kernel/OVR_SysFile.h @ 1:e2f9e4603129

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