core/systems/LibrarySys.h
changeset 141 1ea0bd016431
child 145 473df5b9878e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/systems/LibrarySys.h	Sun Nov 05 02:47:13 2006 +0000
     1.3 @@ -0,0 +1,65 @@
     1.4 +#ifndef _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
     1.5 +#define _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
     1.6 +
     1.7 +#include <ILibrarySys.h>
     1.8 +#include "sm_platform.h"
     1.9 +
    1.10 +using namespace SourceMod;
    1.11 +
    1.12 +#if defined PLATFORM_WINDOWS
    1.13 +typedef HMODULE		LibraryHandle;
    1.14 +#else if defined PLATFORM_POSIX
    1.15 +typedef void *		LibraryHandle;
    1.16 +#endif
    1.17 +
    1.18 +class CDirectory : public IDirectory
    1.19 +{
    1.20 +public:
    1.21 +	CDirectory(const char *path);
    1.22 +	~CDirectory();
    1.23 +public:
    1.24 +	virtual bool MoreFiles();
    1.25 +	virtual void NextEntry();
    1.26 +	virtual const char *GetEntryName();
    1.27 +	virtual bool IsEntryDirectory();
    1.28 +	virtual bool IsEntryFile();
    1.29 +public:
    1.30 +	bool IsValid();
    1.31 +private:
    1.32 +#if defined PLATFORM_WINDOWS
    1.33 +	HANDLE m_dir;
    1.34 +	WIN32_FIND_DATAA m_fd;
    1.35 +#else if defined PLATFORM_LINUX
    1.36 +	DIR *m_dir;
    1.37 +	struct dirent *ep;
    1.38 +	char m_origpath[PLATFORM_MAX_PATH];
    1.39 +#endif
    1.40 +};
    1.41 +
    1.42 +class CLibrary : public ILibrary
    1.43 +{
    1.44 +public:
    1.45 +	CLibrary(LibraryHandle me);
    1.46 +	~CLibrary();
    1.47 +public:
    1.48 +	virtual void CloseLibrary();
    1.49 +	virtual void *GetSymbolAddress(const char *symname);
    1.50 +private:
    1.51 +	LibraryHandle m_lib;
    1.52 +};
    1.53 +
    1.54 +class LibrarySystem
    1.55 +{
    1.56 +public:
    1.57 +	virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
    1.58 +	virtual IDirectory *OpenDirectory(const char *path);
    1.59 +	virtual void CloseDirectory(IDirectory *dir);
    1.60 +	virtual bool PathExists(const char *path);
    1.61 +	virtual bool IsPathFile(const char *path);
    1.62 +	virtual bool IsPathDirectory(const char *path);
    1.63 +	virtual void GetPlatformError(char *error, size_t err_max);
    1.64 +};
    1.65 +
    1.66 +extern LibrarySystem g_LibSys;
    1.67 +
    1.68 +#endif //_INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_