Bug #1043 » T1043.patch
| include/exiv2/basicio.hpp (working copy) | ||
|---|---|---|
| 258 | 258 |
@note This method should be only called after the concerned data (metadata) |
| 259 | 259 |
are all downloaded from the remote file to memory. |
| 260 | 260 |
*/ |
| 261 |
virtual void populateFakeData() {}
|
|
| 261 |
virtual void populateFakeData() {}
|
|
| 262 | 262 |
//@} |
| 263 | 263 | |
| 264 | 264 |
protected: |
| ... | ... | |
| 684 | 684 |
#else |
| 685 | 685 |
virtual int seek(long offset, Position pos); |
| 686 | 686 |
#endif |
| 687 |
/*!
|
|
| 687 |
/*!
|
|
| 688 | 688 |
@brief Allow direct access to the underlying data buffer. The buffer |
| 689 | 689 |
is not protected against write access in any way, the argument |
| 690 | 690 |
is ignored. |
| ... | ... | |
| 694 | 694 |
*/ |
| 695 | 695 |
virtual byte* mmap(bool /*isWriteable*/ =false); |
| 696 | 696 |
virtual int munmap(); |
| 697 |
virtual int msync();
|
|
| 697 |
int msync(); |
|
| 698 | 698 |
//@} |
| 699 | 699 | |
| 700 | 700 |
//! @name Accessors |
| ... | ... | |
| 1272 | 1272 |
*/ |
| 1273 | 1273 |
EXIV2API long writeFile(const DataBuf& buf, const std::wstring& wpath); |
| 1274 | 1274 |
#endif |
| 1275 |
/*!
|
|
| 1275 |
/*!
|
|
| 1276 | 1276 |
@brief replace each substring of the subject that matches the given search string with the given replacement. |
| 1277 | 1277 |
@return the subject after replacing. |
| 1278 | 1278 |
*/ |
| 1279 | 1279 |
EXIV2API std::string ReplaceStringInPlace(std::string subject, const std::string& search, |
| 1280 | 1280 |
const std::string& replace); |
| 1281 | 1281 |
#ifdef EXV_UNICODE_PATH |
| 1282 |
/*!
|
|
| 1282 |
/*!
|
|
| 1283 | 1283 |
@brief Like ReplaceStringInPlace() but accepts a unicode path in an std::wstring. |
| 1284 | 1284 |
@return the subject after replacing. |
| 1285 | 1285 |
@note This function is only available on Windows. |
| src/basicio.cpp (working copy) | ||
|---|---|---|
| 125 | 125 |
struct StructStat {
|
| 126 | 126 |
StructStat() : st_mode(0), st_size(0), st_nlink(0) {}
|
| 127 | 127 |
mode_t st_mode; //!< Permissions |
| 128 |
off_t st_size; //!< Size
|
|
| 128 |
off_t st_size; //!< Size
|
|
| 129 | 129 |
nlink_t st_nlink; //!< Number of hard links (broken on Windows, see winNumberOfLinks()) |
| 130 | 130 |
}; |
| 131 | 131 |
// #endif |
| ... | ... | |
| 256 | 256 |
if (0 == ret) {
|
| 257 | 257 |
buf.st_size = st.st_size; |
| 258 | 258 |
buf.st_nlink = st.st_nlink; |
| 259 |
buf.st_mode = st.st_mode;
|
|
| 259 |
buf.st_mode = st.st_mode;
|
|
| 260 | 260 |
} |
| 261 | 261 |
} |
| 262 | 262 |
return ret; |
| ... | ... | |
| 681 | 681 |
close(); |
| 682 | 682 | |
| 683 | 683 |
bool statOk = true; |
| 684 |
mode_t origStMode = 0;
|
|
| 685 |
std::string spf;
|
|
| 684 |
mode_t origStMode = 0;
|
|
| 685 |
std::string spf;
|
|
| 686 | 686 |
char* pf = 0; |
| 687 | 687 |
#ifdef EXV_UNICODE_PATH |
| 688 | 688 |
std::wstring wspf; |
| ... | ... | |
| 735 | 735 |
if (p_->stat(buf1) == -1) {
|
| 736 | 736 |
statOk = false; |
| 737 | 737 |
} |
| 738 |
origStMode = buf1.st_mode;
|
|
| 738 |
origStMode = buf1.st_mode;
|
|
| 739 | 739 |
#endif // !EXV_HAVE_LSTAT |
| 740 | 740 | |
| 741 | 741 |
// MSVCRT rename that does not overwrite existing files |
| ... | ... | |
| 859 | 859 |
EXV_WARNING << Error(2, pf, strError(), "::stat") << "\n"; |
| 860 | 860 |
#endif |
| 861 | 861 |
} |
| 862 |
if (statOk && origStMode != buf2.st_mode) {
|
|
| 862 |
if (statOk && origStMode != buf2.st_mode) {
|
|
| 863 | 863 |
// Set original file permissions |
| 864 | 864 |
if (::chmod(pf, origStMode) == -1) {
|
| 865 | 865 |
#ifndef SUPPRESS_WARNINGS |
| ... | ... | |
| 867 | 867 |
#endif |
| 868 | 868 |
} |
| 869 | 869 |
} |
| 870 |
}
|
|
| 870 |
}
|
|
| 871 | 871 |
} // if (fileIo) |
| 872 | 872 |
else {
|
| 873 | 873 |
// Generic handling, reopen both to reset to start |
| ... | ... | |
| 1199 | 1199 |
MemIo *memIo = dynamic_cast<MemIo*>(&src); |
| 1200 | 1200 |
if (memIo) {
|
| 1201 | 1201 |
// Optimization if src is another instance of MemIo |
| 1202 |
if (true == p_->isMalloced_) {
|
|
| 1202 |
if (p_->isMalloced_) {
|
|
| 1203 |
msync(); |
|
| 1203 | 1204 |
std::free(p_->data_); |
| 1204 | 1205 |
} |
| 1205 | 1206 |
p_->idx_ = 0; |
| ... | ... | |
| 1287 | 1288 | |
| 1288 | 1289 |
int MemIo::munmap() |
| 1289 | 1290 |
{
|
| 1290 |
msync(); |
|
| 1291 |
return 0; |
|
| 1291 |
return msync(); |
|
| 1292 | 1292 |
} |
| 1293 | 1293 | |
| 1294 | 1294 |
int MemIo::msync() |
| 1295 | 1295 |
{
|
| 1296 | 1296 |
#ifdef MS_SYNC |
| 1297 |
return ::msync(p_, p_->size_, MS_SYNC);
|
|
| 1297 |
return ::msync(p_, p_->size_, MS_SYNC);
|
|
| 1298 | 1298 |
#else |
| 1299 |
return 0;
|
|
| 1299 |
return 0;
|
|
| 1300 | 1300 |
#endif |
| 1301 | 1301 |
} |
| 1302 | 1302 | |