1.1 --- a/core/interfaces/ILibrarySys.h Fri Jan 19 05:25:43 2007 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,155 +0,0 @@
1.4 -#ifndef _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
1.5 -#define _INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_
1.6 -
1.7 -#include <IShareSys.h>
1.8 -
1.9 -namespace SourceMod
1.10 -{
1.11 - #define SMINTERFACE_LIBRARYSYS_NAME "ILibrarySys"
1.12 - #define SMINTERFACE_LIBRARYSYS_VERSION 1
1.13 -
1.14 - class ILibrary
1.15 - {
1.16 - public:
1.17 - virtual ~ILibrary()
1.18 - {
1.19 - /* Calling delete will call CloseLibrary! */
1.20 - };
1.21 - public:
1.22 - /**
1.23 - * @brief Closes dynamic library and invalidates pointer.
1.24 - */
1.25 - virtual void CloseLibrary() =0;
1.26 -
1.27 - /**
1.28 - * @brief Retrieves a symbol pointer from the dynamic library.
1.29 - *
1.30 - * @param symname Symbol name.
1.31 - * @return Symbol pointer, NULL if not found.
1.32 - */
1.33 - virtual void *GetSymbolAddress(const char *symname) =0;
1.34 - };
1.35 -
1.36 - /**
1.37 - * @brief Directory browsing abstraction.
1.38 - */
1.39 - class IDirectory
1.40 - {
1.41 - public:
1.42 - virtual ~IDirectory()
1.43 - {
1.44 - }
1.45 - public:
1.46 - /**
1.47 - * @brief Returns true if there are more files to read, false otherwise.
1.48 - */
1.49 - virtual bool MoreFiles() =0;
1.50 -
1.51 - /**
1.52 - * @brief Advances to the next entry in the stream.
1.53 - */
1.54 - virtual void NextEntry() =0;
1.55 -
1.56 - /**
1.57 - * @brief Returns the name of the current entry.
1.58 - */
1.59 - virtual const char *GetEntryName() =0;
1.60 -
1.61 - /**
1.62 - * @brief Returns whether the current entry is a directory.
1.63 - */
1.64 - virtual bool IsEntryDirectory() =0;
1.65 -
1.66 - /**
1.67 - * @brief Returns whether the current entry is a file.
1.68 - */
1.69 - virtual bool IsEntryFile() =0;
1.70 -
1.71 - /**
1.72 - * @brief Returns true if the current entry is valid
1.73 - * (Used similarly to MoreFiles).
1.74 - */
1.75 - virtual bool IsEntryValid() =0;
1.76 - };
1.77 -
1.78 - /**
1.79 - * @brief Contains various operating system specific code.
1.80 - */
1.81 - class ILibrarySys : public SMInterface
1.82 - {
1.83 - public:
1.84 - virtual const char *GetInterfaceName()
1.85 - {
1.86 - return SMINTERFACE_LIBRARYSYS_NAME;
1.87 - }
1.88 - virtual unsigned int GetInterfaceVersion()
1.89 - {
1.90 - return SMINTERFACE_LIBRARYSYS_VERSION;
1.91 - }
1.92 - public:
1.93 - /**
1.94 - * @brief Opens a dynamic library file.
1.95 - *
1.96 - * @param path Path to library file (.dll/.so).
1.97 - * @param error Buffer for any error message (may be NULL).
1.98 - * @param err_max Maximum length of error buffer.
1.99 - * @return Pointer to an ILibrary, NULL if failed.
1.100 - */
1.101 - virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max) =0;
1.102 -
1.103 - /**
1.104 - * @brief Opens a directory for reading.
1.105 - *
1.106 - * @param path Path to directory.
1.107 - * @return Pointer to an IDirectory, NULL if failed.
1.108 - */
1.109 - virtual IDirectory *OpenDirectory(const char *path) =0;
1.110 -
1.111 - /**
1.112 - * @brief Closes a directory and frees its handle.
1.113 - *
1.114 - * @param dir Pointer to IDirectory.
1.115 - */
1.116 - virtual void CloseDirectory(IDirectory *dir) =0;
1.117 -
1.118 - /**
1.119 - * @brief Returns true if a path exists.
1.120 - */
1.121 - virtual bool PathExists(const char *path) =0;
1.122 -
1.123 - /**
1.124 - * @brief Returns true if the path is a normal file.
1.125 - */
1.126 - virtual bool IsPathFile(const char *path) =0;
1.127 -
1.128 - /**
1.129 - * @brief Returns true if the path is a normal directory.
1.130 - */
1.131 - virtual bool IsPathDirectory(const char *path) =0;
1.132 -
1.133 - /**
1.134 - * @brief Gets a platform-specific error message.
1.135 - * This should only be called when an ILibrary function fails.
1.136 - * Win32 equivalent: GetLastError() + FormatMessage()
1.137 - * POSIX equivalent: errno + strerror()
1.138 - *
1.139 - * @param error Error message buffer.
1.140 - * @param err_max Maximum length of error buffer.
1.141 - */
1.142 - virtual void GetPlatformError(char *error, size_t err_max) =0;
1.143 -
1.144 - /**
1.145 - * @brief Formats a string similar to snprintf(), except
1.146 - * corrects all non-platform compatible path separators to be
1.147 - * the correct platform character.
1.148 - *
1.149 - * @param buffer Output buffer pointer.
1.150 - * @param maxlength Output buffer size.
1.151 - * @param pathfmt Format string of path.
1.152 - * @param ... Format string arguments.
1.153 - */
1.154 - virtual size_t PathFormat(char *buffer, size_t maxlength, const char *pathfmt, ...) =0;
1.155 - };
1.156 -};
1.157 -
1.158 -#endif //_INCLUDE_SOURCEMOD_LIBRARY_INTERFACE_SYS_H_