2007-01-25 23:36:38 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-08-01 04:12:47 +02:00
|
|
|
* ================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
|
|
|
* ================================================================
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
2007-08-01 04:12:47 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License,
|
|
|
|
* version 3.0, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to
|
|
|
|
* link the code of this program (as well as its derivative works) to
|
|
|
|
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
|
|
|
|
* Game MODs that run on software by the Valve Corporation. You must
|
|
|
|
* obey the GNU General Public License in all respects for all other
|
|
|
|
* code used. Additionally, AlliedModders LLC grants this exception
|
|
|
|
* to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version
|
|
|
|
* JULY-31-2007), or <http://www.sourcemod.net/license.php>.
|
2007-01-25 23:36:38 +01:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
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;
|
2007-01-25 10:19:38 +01:00
|
|
|
#elif defined PLATFORM_POSIX
|
2006-11-05 03:47:13 +01:00
|
|
|
typedef void * LibraryHandle;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class CDirectory : public IDirectory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CDirectory(const char *path);
|
|
|
|
~CDirectory();
|
|
|
|
public:
|
2007-03-17 01:55:46 +01:00
|
|
|
bool MoreFiles();
|
|
|
|
void NextEntry();
|
|
|
|
const char *GetEntryName();
|
|
|
|
bool IsEntryDirectory();
|
|
|
|
bool IsEntryFile();
|
|
|
|
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;
|
2007-01-25 10:19:38 +01:00
|
|
|
#elif defined PLATFORM_POSIX
|
2006-11-05 03:47:13 +01:00
|
|
|
DIR *m_dir;
|
|
|
|
struct dirent *ep;
|
|
|
|
char m_origpath[PLATFORM_MAX_PATH];
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
class CLibrary : public ILibrary
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLibrary(LibraryHandle me);
|
|
|
|
~CLibrary();
|
|
|
|
public:
|
2007-03-17 01:55:46 +01:00
|
|
|
void CloseLibrary();
|
|
|
|
void *GetSymbolAddress(const char *symname);
|
2006-11-05 03:47:13 +01:00
|
|
|
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:
|
2007-05-08 02:21:44 +02:00
|
|
|
ILibrary *OpenLibrary(const char *path, char *error, size_t maxlength);
|
2007-03-17 01:55:46 +01:00
|
|
|
IDirectory *OpenDirectory(const char *path);
|
|
|
|
void CloseDirectory(IDirectory *dir);
|
|
|
|
bool PathExists(const char *path);
|
|
|
|
bool IsPathFile(const char *path);
|
|
|
|
bool IsPathDirectory(const char *path);
|
2007-05-08 02:21:44 +02:00
|
|
|
void GetPlatformError(char *error, size_t maxlength);
|
2007-03-17 01:55:46 +01:00
|
|
|
size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
|
2007-05-14 23:29:17 +02:00
|
|
|
const char *GetFileExtension(const char *filename);
|
2007-07-27 20:24:09 +02:00
|
|
|
bool CreateFolder(const char *path);
|
2007-06-18 09:04:22 +02:00
|
|
|
size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path);
|
2006-11-05 03:47:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern LibrarySystem g_LibSys;
|
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_SYSTEM_LIBRARY_H_
|