fix for amb1595

--HG--
branch : sourcemod-1.0.x
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.0.x%402005
This commit is contained in:
David Anderson 2008-04-08 23:24:30 +00:00
parent 2c74333d47
commit a0833bfd10
2 changed files with 19 additions and 11 deletions

View File

@ -286,11 +286,23 @@ void LibrarySystem::GetPlatformError(char *error, size_t maxlength)
maxlength,
NULL);
#elif defined PLATFORM_POSIX
snprintf(error, maxlength, "%s", strerror(errno));
UTIL_Format(error, maxlength, "%s", strerror(errno));
#endif
}
}
void LibrarySystem::GetLoaderError(char *buffer, size_t maxlength)
{
#if defined PLATFORM_WINDOWS
GetPlatformError(buffer, maxlength);
#elif defined PLATFORM_POSIX
if (buffer != NULL && maxlength)
{
strncopy(buffer, dlerror(), maxlength);
}
#endif
}
void LibrarySystem::CloseDirectory(IDirectory *dir)
{
delete dir;
@ -301,20 +313,15 @@ ILibrary *LibrarySystem::OpenLibrary(const char *path, char *error, size_t maxle
LibraryHandle lib;
#if defined PLATFORM_WINDOWS
lib = LoadLibraryA(path);
if (!lib)
{
GetPlatformError(error, maxlength);
return false;
}
#elif defined PLATFORM_POSIX
lib = dlopen(path, RTLD_NOW);
if (!lib)
{
GetPlatformError(error, maxlength);
return false;
}
#endif
if (lib == NULL)
{
GetLoaderError(error, maxlength);
}
return new CLibrary(lib);
}

View File

@ -95,6 +95,7 @@ public:
bool CreateFolder(const char *path);
size_t GetFileFromPath(char *buffer, size_t maxlength, const char *path);
bool FileTime(const char *path, FileTimeType type, time_t *pTime);
void GetLoaderError(char *buffer, size_t maxlength);
};
extern LibrarySystem g_LibSys;