#pragma region CPL License /* Nuclex Engine Copyright (C) 2002-2008 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library 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 IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion #ifndef NUCLEX_PLUGINS_RAR_RARPLUGIN_H #define NUCLEX_PLUGINS_RAR_RARPLUGIN_H #include "Nuclex/Nuclex.h" #include "Nuclex/Support/Synchronization.h" #include "Nuclex/Support/String.h" #include "Nuclex/Support/Exception.h" #define WIN32_LEAN_AND_MEAN #include #include // The following block will decide whether symbols are imported from a // dll (client app) or exported to a dll (nuclex library). // The RARPLUGIN_EXPORTS symbol should only be used for compiling // the Nuclex.Plugins.Rar library and nowhere else. // #ifdef RARPLUGIN_EXPORTS #define RARPLUGIN_API __declspec(dllexport) #else #define RARPLUGIN __declspec(dllimport) #endif namespace Nuclex { // ------------------------------------------------------------------------------------------- // /// Get the mutex used for all threaded operations on RAR /// The mutex to use for all threaded operations on RAR RARPLUGIN_API Mutex &getRarMutex(); // ------------------------------------------------------------------------------------------- // /// Checks a result code returned by the RAR API /// Source of the call /// Method being called /// Method result code inline void RarCheck(const string &sSource, const string &sMethod, int nResult) { if(nResult) { string sError = string("Unexpected failure in ") + sMethod + ": "; switch(nResult) { case ERAR_END_ARCHIVE: { sError += "End of archive reached"; break; } case ERAR_NO_MEMORY: { sError += "Out of memory"; break; } case ERAR_BAD_DATA: { sError += "Data corrupted or wrong password"; break; } case ERAR_BAD_ARCHIVE: { sError += "Archive damaged"; break; } case ERAR_UNKNOWN_FORMAT: { sError += "Unsupported archive format"; break; } case ERAR_EOPEN: { sError += "Can't open file"; break; } case ERAR_ECREATE: { sError += "Unable to create file"; break; } case ERAR_ECLOSE: { sError += "Can't close file"; break; } case ERAR_EREAD: { sError += "Read error"; break; } case ERAR_EWRITE: { sError += "Write error"; break; } case ERAR_SMALL_BUF: { sError += "Buffer too small"; break; } case ERAR_UNKNOWN: { sError += "Unknown error"; break; } default: { sError += "Unknown result code"; break; } } throw UnexpectedException(sSource, sError); } } } // namespace Nuclex #endif // NUCLEX_PLUGINS_RAR_RARPLUGIN_H