dvander@370: /** ds@653: * vim: set ts=4 : ds@1330: * ============================================================================= dvander@1231: * SourceMod ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. ds@1330: * ============================================================================= dvander@370: * ds@1330: * This program is free software; you can redistribute it and/or modify it under ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the ds@1330: * Free Software Foundation. dvander@1231: * ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1330: * details. dvander@1231: * ds@1330: * You should have received a copy of the GNU General Public License along with ds@1330: * this program. If not, see . dvander@1231: * ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1330: * this exception to all derivative works. AlliedModders LLC defines further ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1330: * or . dvander@370: * dvander@370: * Version: $Id$ dvander@370: */ dvander@370: dvander@141: #ifndef _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_ dvander@141: #define _INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_ dvander@141: dvander@141: #include dvander@141: #include "sm_platform.h" dvander@141: dvander@141: using namespace SourceMod; dvander@141: dvander@141: #if defined PLATFORM_WINDOWS dvander@141: typedef HMODULE LibraryHandle; dvander@351: #elif defined PLATFORM_POSIX dvander@141: typedef void * LibraryHandle; dvander@141: #endif dvander@141: dvander@141: class CDirectory : public IDirectory dvander@141: { dvander@141: public: dvander@141: CDirectory(const char *path); dvander@141: ~CDirectory(); dvander@141: public: faluco@641: bool MoreFiles(); faluco@641: void NextEntry(); faluco@641: const char *GetEntryName(); faluco@641: bool IsEntryDirectory(); faluco@641: bool IsEntryFile(); faluco@641: bool IsEntryValid(); dvander@141: public: dvander@141: bool IsValid(); dvander@141: private: dvander@141: #if defined PLATFORM_WINDOWS dvander@141: HANDLE m_dir; dvander@141: WIN32_FIND_DATAA m_fd; dvander@351: #elif defined PLATFORM_POSIX dvander@141: DIR *m_dir; dvander@141: struct dirent *ep; dvander@141: char m_origpath[PLATFORM_MAX_PATH]; dvander@141: #endif dvander@141: }; dvander@141: dvander@141: class CLibrary : public ILibrary dvander@141: { dvander@141: public: dvander@141: CLibrary(LibraryHandle me); dvander@141: ~CLibrary(); dvander@141: public: faluco@641: void CloseLibrary(); faluco@641: void *GetSymbolAddress(const char *symname); dvander@141: private: dvander@141: LibraryHandle m_lib; dvander@141: }; dvander@141: dvander@145: class LibrarySystem : public ILibrarySys dvander@141: { dvander@141: public: ds@755: ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength); faluco@641: IDirectory *OpenDirectory(const char *path); faluco@641: void CloseDirectory(IDirectory *dir); faluco@641: bool PathExists(const char *path); faluco@641: bool IsPathFile(const char *path); faluco@641: bool IsPathDirectory(const char *path); ds@755: void GetPlatformError(char *error, size_t maxlength); dvander@2474: void GetPlatformErrorEx(int code, char *error, size_t maxlength); faluco@641: size_t PathFormat(char *buffer, size_t len, const char *fmt, ...); ds@794: const char *GetFileExtension(const char *filename); dvander@1192: bool CreateFolder(const char *path); dvander@978: size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path); dvander@1738: bool FileTime(const char *path, FileTimeType type, time_t *pTime); dvander@1974: void GetLoaderError(char *buffer, size_t maxlength); dvander@141: }; dvander@141: dvander@141: extern LibrarySystem g_LibSys; dvander@141: dvander@141: #endif //_INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_