#1152 Fix submitted. Also added new static function FileIo::temporaryPath() which I require for tgt - code and fixed typo in tiffvisitor.cpp

v0.27.3
Robin Mills 10 years ago
parent b703575389
commit 04f871cc4c

@ -544,6 +544,11 @@ namespace Exiv2 {
virtual void populateFakeData(); virtual void populateFakeData();
//@} //@}
/*!
@brief Returns the path to a temporary data storage location.
*/
static std::string temporaryPath();
private: private:
// NOT IMPLEMENTED // NOT IMPLEMENTED
//! Copy constructor //! Copy constructor

@ -273,7 +273,7 @@ namespace Exiv2 {
# if defined(EXV_UNICODE_PATH) # if defined(EXV_UNICODE_PATH)
# error No xattr API for MacOS X with unicode support # error No xattr API for MacOS X with unicode support
# endif # endif
const ssize_t namebufSize = ::listxattr(src.p_->path_.c_str(), 0, 0, 0); ssize_t namebufSize = ::listxattr(src.p_->path_.c_str(), 0, 0, 0);
if (namebufSize < 0) { if (namebufSize < 0) {
throw Error(2, src.p_->path_, strError(), "listxattr"); throw Error(2, src.p_->path_, strError(), "listxattr");
} }
@ -282,7 +282,7 @@ namespace Exiv2 {
return; return;
} }
char* namebuf = new char[namebufSize]; char* namebuf = new char[namebufSize];
if (::listxattr(src.p_->path_.c_str(), namebuf, sizeof(namebuf), 0) != namebufSize) { if (::listxattr(src.p_->path_.c_str(), namebuf, namebufSize, 0) != namebufSize) {
throw Error(2, src.p_->path_, strError(), "listxattr"); throw Error(2, src.p_->path_, strError(), "listxattr");
} }
for (ssize_t namebufPos = 0; namebufPos < namebufSize;) { for (ssize_t namebufPos = 0; namebufPos < namebufSize;) {
@ -293,7 +293,7 @@ namespace Exiv2 {
throw Error(2, src.p_->path_, strError(), "getxattr"); throw Error(2, src.p_->path_, strError(), "getxattr");
} }
char* value = new char[valueSize]; char* value = new char[valueSize];
if (::getxattr(src.p_->path_.c_str(), name, value, sizeof(value), 0, 0) != valueSize) { if (::getxattr(src.p_->path_.c_str(), name, value, valueSize, 0, 0) != valueSize) {
throw Error(2, src.p_->path_, strError(), "getxattr"); throw Error(2, src.p_->path_, strError(), "getxattr");
} }
// #906. Mountain Lion 'sandbox' terminates the app when we call setxattr // #906. Mountain Lion 'sandbox' terminates the app when we call setxattr
@ -619,6 +619,28 @@ namespace Exiv2 {
return basicIo; return basicIo;
} }
std::string FileIo::temporaryPath()
{
static int count = 0 ;
char sCount[12];
sprintf(sCount,"_%d",count++);
#ifdef _MSC_VER
char lpTempPathBuffer[MAX_PATH];
GetTempPath(MAX_PATH,lpTempPathBuffer);
std::string tmp(lpTempPathBuffer);
tmp += "\\";
#else
std::string tmp = "/tmp/";
#endif
pid_t pid = ::getpid();
std::string result = tmp + toString(pid) + sCount ;
if ( Exiv2::fileExists(result) ) std::remove(result.c_str());
return result;
}
long FileIo::write(const byte* data, long wcount) long FileIo::write(const byte* data, long wcount)
{ {
assert(p_->fp_ != 0); assert(p_->fp_ != 0);

@ -1541,7 +1541,7 @@ namespace Exiv2 {
// Sadly: we don't know the exact location of the image in the source (it's near offset) // Sadly: we don't know the exact location of the image in the source (it's near offset)
// And neither TiffReader nor TiffEntryBase have access to the BasicIo object being processed // And neither TiffReader nor TiffEntryBase have access to the BasicIo object being processed
byte* buffer = (byte*) ::malloc(isize); byte* buffer = (byte*) ::malloc(isize);
::memset(buffer,isize,0); ::memset(buffer,0,isize);
v->read(buffer,isize, byteOrder()); v->read(buffer,isize, byteOrder());
::free(buffer); ::free(buffer);
} }

Loading…
Cancel
Save