core/systems/LibrarySys.h
author David Anderson <dvander@alliedmods.net>
Mon Nov 06 10:57:37 2006 +0000 (2006-11-06)
changeset 145 473df5b9878e
parent 141 1ea0bd016431
child 206 04c8442bd9d1
permissions -rw-r--r--
renamed mm_api, I don't like short names!
finished and tested the INI parser and its API
     1 #ifndef _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
     2 #define _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
     3 
     4 #include <ILibrarySys.h>
     5 #include "sm_platform.h"
     6 
     7 using namespace SourceMod;
     8 
     9 #if defined PLATFORM_WINDOWS
    10 typedef HMODULE		LibraryHandle;
    11 #else if defined PLATFORM_POSIX
    12 typedef void *		LibraryHandle;
    13 #endif
    14 
    15 class CDirectory : public IDirectory
    16 {
    17 public:
    18 	CDirectory(const char *path);
    19 	~CDirectory();
    20 public:
    21 	virtual bool MoreFiles();
    22 	virtual void NextEntry();
    23 	virtual const char *GetEntryName();
    24 	virtual bool IsEntryDirectory();
    25 	virtual bool IsEntryFile();
    26 public:
    27 	bool IsValid();
    28 private:
    29 #if defined PLATFORM_WINDOWS
    30 	HANDLE m_dir;
    31 	WIN32_FIND_DATAA m_fd;
    32 #else if defined PLATFORM_LINUX
    33 	DIR *m_dir;
    34 	struct dirent *ep;
    35 	char m_origpath[PLATFORM_MAX_PATH];
    36 #endif
    37 };
    38 
    39 class CLibrary : public ILibrary
    40 {
    41 public:
    42 	CLibrary(LibraryHandle me);
    43 	~CLibrary();
    44 public:
    45 	virtual void CloseLibrary();
    46 	virtual void *GetSymbolAddress(const char *symname);
    47 private:
    48 	LibraryHandle m_lib;
    49 };
    50 
    51 class LibrarySystem : public ILibrarySys
    52 {
    53 public:
    54 	virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
    55 	virtual IDirectory *OpenDirectory(const char *path);
    56 	virtual void CloseDirectory(IDirectory *dir);
    57 	virtual bool PathExists(const char *path);
    58 	virtual bool IsPathFile(const char *path);
    59 	virtual bool IsPathDirectory(const char *path);
    60 	virtual void GetPlatformError(char *error, size_t err_max);
    61 };
    62 
    63 extern LibrarySystem g_LibSys;
    64 
    65 #endif //_INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_