gwnavruntime/kernel/SF_SysFile.h Source File

SF_SysFile.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 /**************************************************************************
8 
9 PublicHeader: Kernel
10 Filename : KY_SysFile.h
11 Content : Header for all internal file management-
12  functions and structures to be inherited by OS
13  specific subclasses.
14 Created : July 29, 1998
15 Authors : Michael Antonov, Brendan Iribe, Andrew Reisse
16 
17 Notes : errno may not be preserved across use of GBaseFile member functions
18  : Directories cannot be deleted while files opened from them are in use
19  (For the GetFullName function)
20 
21 **************************************************************************/
22 
23 #ifndef INC_KY_Kernel_SysFile_H
24 #define INC_KY_Kernel_SysFile_H
25 
27 
28 namespace Kaim {
29 
30 // ***** Declared classes
31 class SysFile;
32 
33 // *** File Statistics
34 
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;
43 
44  bool operator== (const FileStat& stat) const
45  {
46  return ( (ModifyTime == stat.ModifyTime) &&
47  (AccessTime == stat.AccessTime) &&
48  (FileSize == stat.FileSize) );
49  }
50 };
51 
52 // *** System File
53 
54 // System file is created to access objects on file system directly
55 // This file can refer directly to path.
56 // System file can be open & closed several times; however, such use is not recommended
57 // This class is realy a wrapper around an implementation of File interface for a
58 // particular platform.
59 
60 class SysFile : public DelegatedFile
61 {
62 protected:
63  SysFile(const SysFile &source) : DelegatedFile () { KY_UNUSED(source); }
64 public:
65 
66  // ** Constructor
67  KY_EXPORT SysFile();
68  // Opens a file
69  // For some platforms (PS2,PSP,Wii) buffering will be used even if Open_Buffered flag is not set because
70  // of these platforms' file system limitation.
71  KY_EXPORT SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
72 
73  // ** Open & management
74  // Will fail if file's already open
75  // For some platforms (PS2,PSP,Wii) buffering will be used even if Open_Buffered flag is not set because
76  // of these platforms' file system limitation.
77  KY_EXPORT bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite);
78 
79  KY_INLINE bool Create(const String& path, int mode = Mode_ReadWrite)
80  { return Open(path, Open_ReadWrite|Open_Create, mode); }
81 
82  // Helper function: obtain file statistics information. In GFx, this is used to detect file changes.
83  // Return 0 if function failed, most likely because the file doesn't exist.
84  KY_EXPORT static bool KY_CDECL GetFileStat(FileStat* pfileStats, const String& path);
85 
86  // ** Overrides
87  // Overridden to provide re-open support
88  KY_EXPORT virtual int GetErrorCode();
89 
90  KY_EXPORT virtual bool IsValid();
91 
92  KY_EXPORT virtual bool Close();
93  //SF_EXPORT virtual bool CloseCancel();
94 
95 #ifdef KY_OS_WIIU
96  static void initializeSysFileSystem();
97  static void shutdownSysFileSystem();
98 #endif
99 };
100 
101 } // Kaim
102 
103 #endif
Definition: gamekitcrowddispersion.h:20