MinGW and MSVC fixes.

This commit is contained in:
Andreas Huggel
2010-01-18 16:34:16 +00:00
parent ba5a7b9075
commit 9b4f4f84d6
4 changed files with 16 additions and 14 deletions
+3 -1
View File
@@ -18,7 +18,9 @@ int main()
throw Exiv2::WError(-1, L"WARG1", L"WARG2", L"WARG3");
}
catch (const Exiv2::WError& e) {
std::wcout << "Caught WError '" << e.wwhat() << "'\n";
std::wstring wmsg = e.wwhat();
std::string msg(wmsg.begin(), wmsg.end());
std::cout << "Caught WError '" << msg << "'\n";
}
return 0;
+6 -6
View File
@@ -502,10 +502,10 @@ namespace Exiv2 {
#ifdef EXV_UNICODE_PATH
if (p_->wpMode_ == Impl::wpUnicode) {
if (fileExists(wpf) && ::_wremove(wpf) != 0) {
throw WError(2, wpf, strError(), "::_wremove");
throw WError(2, wpf, strError().c_str(), "::_wremove");
}
if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) {
throw WError(17, fileIo->wpath(), wpf, strError());
throw WError(17, fileIo->wpath(), wpf, strError().c_str());
}
::_wremove(fileIo->wpath().c_str());
// Check permissions of new file
@@ -998,16 +998,16 @@ namespace Exiv2 {
{
FileIo file(wpath);
if (file.open("rb") != 0) {
throw WError(10, wpath, "rb", strError());
throw WError(10, wpath, "rb", strError().c_str());
}
struct _stat st;
if (0 != ::_wstat(wpath.c_str(), &st)) {
throw WError(2, wpath, strError(), "::_wstat");
throw WError(2, wpath, strError().c_str(), "::_wstat");
}
DataBuf buf(st.st_size);
long len = file.read(buf.pData_, buf.size_);
if (len != buf.size_) {
throw WError(2, wpath, strError(), "FileIo::read");
throw WError(2, wpath, strError().c_str(), "FileIo::read");
}
return buf;
}
@@ -1027,7 +1027,7 @@ namespace Exiv2 {
{
FileIo file(wpath);
if (file.open("wb") != 0) {
throw WError(10, wpath, "wb", strError());
throw WError(10, wpath, "wb", strError().c_str());
}
return file.write(buf.pData_, buf.size_);
}
+6 -6
View File
@@ -94,7 +94,7 @@ namespace Exiv2 {
provided to print errors to a stream.
*/
template<typename charT>
class EXIV2API BasicError : public AnyError {
class BasicError : public AnyError {
public:
//! @name Creators
//@{
@@ -102,13 +102,13 @@ namespace Exiv2 {
explicit BasicError(int code);
//! Constructor taking an error code and one argument
template<typename A>
EXV_DLLLOCAL BasicError(int code, const A& arg1);
BasicError(int code, const A& arg1);
//! Constructor taking an error code and two arguments
template<typename A, typename B>
EXV_DLLLOCAL BasicError(int code, const A& arg1, const B& arg2);
BasicError(int code, const A& arg1, const B& arg2);
//! Constructor taking an error code and three arguments
template<typename A, typename B, typename C>
EXV_DLLLOCAL BasicError(int code, const A& arg1, const B& arg2, const C& arg3);
BasicError(int code, const A& arg1, const B& arg2, const C& arg3);
//! Virtual destructor. (Needed because of throw())
virtual ~BasicError() throw();
//@}
@@ -120,12 +120,12 @@ namespace Exiv2 {
@brief Return the error message as a C-string. The pointer returned by what()
is valid only as long as the BasicError object exists.
*/
virtual const char* what() const throw();
EXIV2API virtual const char* what() const throw();
/*!
@brief Return the error message as a wchar_t-string. The pointer returned by
wwhat() is valid only as long as the BasicError object exists.
*/
virtual const wchar_t* wwhat() const throw();
EXIV2API virtual const wchar_t* wwhat() const throw();
//@}
private:
+1 -1
View File
@@ -448,7 +448,7 @@ namespace Exiv2 {
std::auto_ptr<FileIo> fileIo(new FileIo(wpath));
// Create or overwrite the file, then close it
if (fileIo->open("w+b") != 0) {
throw WError(10, wpath, "w+b", strError());
throw WError(10, wpath, "w+b", strError().c_str());
}
fileIo->close();
BasicIo::AutoPtr io(fileIo);