2006-11-05 03:47:13 +01:00
|
|
|
#ifndef _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
|
|
|
|
|
|
|
|
#include <ILibrarySys.h>
|
|
|
|
#include "sm_platform.h"
|
|
|
|
|
|
|
|
using namespace SourceMod;
|
|
|
|
|
|
|
|
#if defined PLATFORM_WINDOWS
|
|
|
|
typedef HMODULE LibraryHandle;
|
|
|
|
#else if defined PLATFORM_POSIX
|
|
|
|
typedef void * LibraryHandle;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class CDirectory : public IDirectory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CDirectory(const char *path);
|
|
|
|
~CDirectory();
|
|
|
|
public:
|
|
|
|
virtual bool MoreFiles();
|
|
|
|
virtual void NextEntry();
|
|
|
|
virtual const char *GetEntryName();
|
|
|
|
virtual bool IsEntryDirectory();
|
|
|
|
virtual bool IsEntryFile();
|
2007-01-01 20:50:16 +01:00
|
|
|
virtual bool IsEntryValid();
|
2006-11-05 03:47:13 +01:00
|
|
|
public:
|
|
|
|
bool IsValid();
|
|
|
|
private:
|
|
|
|
#if defined PLATFORM_WINDOWS
|
|
|
|
HANDLE m_dir;
|
|
|
|
WIN32_FIND_DATAA m_fd;
|
|
|
|
#else if defined PLATFORM_LINUX
|
|
|
|
DIR *m_dir;
|
|
|
|
struct dirent *ep;
|
|
|
|
char m_origpath[PLATFORM_MAX_PATH];
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
class CLibrary : public ILibrary
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLibrary(LibraryHandle me);
|
|
|
|
~CLibrary();
|
|
|
|
public:
|
|
|
|
virtual void CloseLibrary();
|
|
|
|
virtual void *GetSymbolAddress(const char *symname);
|
|
|
|
private:
|
|
|
|
LibraryHandle m_lib;
|
|
|
|
};
|
|
|
|
|
2006-11-06 11:57:37 +01:00
|
|
|
class LibrarySystem : public ILibrarySys
|
2006-11-05 03:47:13 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
|
|
|
|
virtual IDirectory *OpenDirectory(const char *path);
|
|
|
|
virtual void CloseDirectory(IDirectory *dir);
|
|
|
|
virtual bool PathExists(const char *path);
|
|
|
|
virtual bool IsPathFile(const char *path);
|
|
|
|
virtual bool IsPathDirectory(const char *path);
|
|
|
|
virtual void GetPlatformError(char *error, size_t err_max);
|
2006-12-13 12:13:50 +01:00
|
|
|
virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
|
2006-11-05 03:47:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern LibrarySystem g_LibSys;
|
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
|