gwnavruntime/kernel/SF_SysFile.h Source File

SF_SysFile.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016 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 #pragma once
8 
10 
11 namespace Kaim
12 {
13 
14 // ***** Declared classes
15 class SysFile;
16 
17 // *** File Statistics
18 
19 // This class contents are similar to _stat, providing
20 // creation, modify and other information about the file.
21 struct FileStat
22 {
23  // No change or create time because they are not available on most systems
24  SInt64 ModifyTime;
25  SInt64 AccessTime;
26  SInt64 FileSize;
27 
28  bool operator==(const FileStat& stat) const { return ((ModifyTime == stat.ModifyTime) && (AccessTime == stat.AccessTime) && (FileSize == stat.FileSize)); }
29 };
30 
31 // *** System File
32 
33 // System file is created to access objects on file system directly
34 // This file can refer directly to path.
35 // System file can be open & closed several times; however, such use is not recommended
36 // This class is really a wrapper around an implementation of File interface for a
37 // particular platform.
38 // The underlying file handler is fclose() in the destructor (when refcount comes to zero)
39 // SysFile --Ptr<File> pFile--> BufferedFile --Ptr<File> pFile--> FILEFile
40 // where FILEFile constructor calls fopen and destructor calls fclose
41 class SysFile : public DelegatedFile
42 {
43 protected:
44  SysFile(const SysFile& source) : DelegatedFile() { KY_UNUSED(source); }
45 
46 public:
47  // ** Constructor
48  SysFile();
49  // Opens a file
50  // For some platforms (PS2,PSP,Wii) buffering will be used even if Open_Buffered flag is not set because
51  // of these platforms' file system limitation.
52  SysFile(const String& path, int flags = Open_Read | Open_Buffered, int mode = Mode_ReadWrite);
53 
54  // ** Open & management
55  // Will fail if file's already open
56  bool Open(const String& path, int flags = Open_Read | Open_Buffered, int mode = Mode_ReadWrite);
57 
58  inline bool Create(const String& path, int mode = Mode_ReadWrite) { return Open(path, Open_ReadWrite | Open_Create, mode); }
59 
60  // Helper function: obtain file statistics information. In GFx, this is used to detect file changes.
61  // Return 0 if function failed, most likely because the file doesn't exist.
62  static bool GetFileStat(FileStat* pfileStats, const String& path);
63 
64  // ** Overrides
65  // Overridden to provide re-open support
66  virtual int GetErrorCode();
67 
68  virtual bool IsValid();
69 
70  virtual bool Close();
71 };
72 
73 } // Kaim
std::int64_t SInt64
int64_t
Definition: SF_Types.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17