fix for amb1595

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402007
This commit is contained in:
David Anderson 2008-04-08 23:35:58 +00:00
parent ea189849de
commit 72b6510e61
2 changed files with 20 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,16 @@ 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 NULL;
}
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;