SourceMod SDK  1.7
ILibrarySys.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
33 #define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
34 
40 #include <IShareSys.h>
41 #include <time.h>
42 
43 namespace SourceMod
44 {
45  #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
46  #define SMINTERFACE_LIBRARYSYS_VERSION 5
47 
48  enum FileTimeType
49  {
50  FileTime_LastAccess = 0, /* Last access (not available on FAT) */
51  FileTime_Created = 1, /* Creation (not available on FAT) */
52  FileTime_LastChange = 2, /* Last modification */
53  };
54 
55  class ILibrary
56  {
57  public:
59  virtual ~ILibrary()
60  {
61  };
62  public:
66  virtual void CloseLibrary() =0;
67 
74  virtual void *GetSymbolAddress(const char *symname) =0;
75  };
76 
80  class IDirectory
81  {
82  public:
84  virtual ~IDirectory()
85  {
86  }
87  public:
91  virtual bool MoreFiles() =0;
92 
96  virtual void NextEntry() =0;
97 
101  virtual const char *GetEntryName() =0;
102 
106  virtual bool IsEntryDirectory() =0;
107 
111  virtual bool IsEntryFile() =0;
112 
117  virtual bool IsEntryValid() =0;
118  };
119 
123  class ILibrarySys : public SMInterface
124  {
125  public:
126  virtual const char *GetInterfaceName()
127  {
128  return SMINTERFACE_LIBRARYSYS_NAME;
129  }
130  virtual unsigned int GetInterfaceVersion()
131  {
132  return SMINTERFACE_LIBRARYSYS_VERSION;
133  }
134  public:
143  virtual ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength) =0;
144 
151  virtual IDirectory *OpenDirectory(const char *path) =0;
152 
158  virtual void CloseDirectory(IDirectory *dir) =0;
159 
163  virtual bool PathExists(const char *path) =0;
164 
168  virtual bool IsPathFile(const char *path) =0;
169 
173  virtual bool IsPathDirectory(const char *path) =0;
174 
184  virtual void GetPlatformError(char *error, size_t maxlength) =0;
185 
196  virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt, ...) =0;
197 
204  virtual const char *GetFileExtension(const char *filename) =0;
205 
212  virtual bool CreateFolder(const char *path) =0;
213 
225  virtual bool FileTime(const char *path, FileTimeType type, time_t *pTime) =0;
226 
235  virtual size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path) =0;
236  };
237 }
238 
239 #endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
virtual bool IsPathFile(const char *path)=0
Returns true if the path is a normal file.
virtual IDirectory * OpenDirectory(const char *path)=0
Opens a directory for reading.
virtual ~IDirectory()
Definition: ILibrarySys.h:84
virtual void CloseDirectory(IDirectory *dir)=0
Closes a directory and frees its handle.
virtual bool PathExists(const char *path)=0
Returns true if a path exists.
virtual bool IsEntryDirectory()=0
Returns whether the current entry is a directory.
virtual ILibrary * OpenLibrary(const char *path, char *error, size_t maxlength)=0
Opens a dynamic library file.
virtual void CloseLibrary()=0
Closes dynamic library and invalidates pointer.
virtual void NextEntry()=0
Advances to the next entry in the stream.
virtual const char * GetInterfaceName()
Must return a string defining the interface's unique name.
Definition: ILibrarySys.h:126
virtual size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path)=0
Retrieve the file component of the given path.
Defines the Share System, responsible for shared resources and dependencies.
virtual void GetPlatformError(char *error, size_t maxlength)=0
Gets a platform-specific error message. This should only be called when an ILibrary function fails...
virtual unsigned int GetInterfaceVersion()
Must return an integer defining the interface's version.
Definition: ILibrarySys.h:130
Defines the base functionality required by a shared interface.
Definition: IShareSys.h:92
virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt,...)=0
Formats a string similar to snprintf(), except corrects all non-platform compatible path separators t...
virtual bool IsPathDirectory(const char *path)=0
Returns true if the path is a normal directory.
virtual bool IsEntryValid()=0
Returns true if the current entry is valid (Used similarly to MoreFiles).
virtual bool IsEntryFile()=0
Returns whether the current entry is a file.
Contains various operating system specific code.
Definition: ILibrarySys.h:123
virtual void * GetSymbolAddress(const char *symname)=0
Retrieves a symbol pointer from the dynamic library.
Definition: IAdminSystem.h:63
virtual const char * GetFileExtension(const char *filename)=0
Returns a pointer to the extension in a filename.
Directory browsing abstraction.
Definition: ILibrarySys.h:80
virtual ~ILibrary()
Definition: ILibrarySys.h:59
virtual bool CreateFolder(const char *path)=0
Creates a directory.
virtual bool MoreFiles()=0
Returns true if there are more files to read, false otherwise.
Definition: ILibrarySys.h:55
virtual bool FileTime(const char *path, FileTimeType type, time_t *pTime)=0
Returns the requested timestamp of a file.
virtual const char * GetEntryName()=0
Returns the name of the current entry.