[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:40:30 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=fca7210
The following commit has been merged in the master branch:
commit fca7210a3f5a35044e8be5dbc9f1a4b4d6a3bff3
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sat May 16 12:09:07 2009 +0000
#633: Fixed FileIo::transfer to operate on the linked-to file if the FileIo is a symlink. Only tested on Linux.
---
src/basicio.cpp | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/src/basicio.cpp b/src/basicio.cpp
index ba141ee..653e5ce 100644
--- a/src/basicio.cpp
+++ b/src/basicio.cpp
@@ -233,33 +233,51 @@ namespace Exiv2 {
close();
bool statOk = true;
struct stat buf1;
- if (::stat(path_.c_str(), &buf1) == -1) {
+ if (::lstat(path_.c_str(), &buf1) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, path_, strError(), "stat") << "
";
+ std::cerr << "Warning: " << Error(2, path_, strError(), "lstat") << "
";
#endif
}
+ // In case path_ is a symlink, get the path of the linked-to file
+ char* pf = const_cast<char*>(path_.c_str());
+ DataBuf lbuf;
+ if (statOk && S_ISLNK(buf1.st_mode)) {
+ lbuf.alloc(buf1.st_size + 1);
+ memset(lbuf.pData_, 0x0, lbuf.size_);
+ pf = reinterpret_cast<char*>(lbuf.pData_);
+ if (readlink(path_.c_str(), pf, lbuf.size_ - 1) == -1) {
+ throw Error(2, path_, strError(), "readlink");
+ }
+ // We need the permissions of the file, not the symlink
+ if (::stat(pf, &buf1) == -1) {
+ statOk = false;
+#ifndef SUPPRESS_WARNINGS
+ std::cerr << "Warning: " << Error(2, pf, strError(), "stat") << "
";
+#endif
+ }
+ }
// MSVCRT rename that does not overwrite existing files
- if (fileExists(path_) && std::remove(path_.c_str()) != 0) {
- throw Error(2, path_, strError(), "std::remove");
+ if (fileExists(pf) && std::remove(pf) != 0) {
+ throw Error(2, pf, strError(), "std::remove");
}
- if (std::rename(fileIo->path_.c_str(), path_.c_str()) == -1) {
- throw Error(17, fileIo->path_, path_, strError());
+ if (std::rename(fileIo->path_.c_str(), pf) == -1) {
+ throw Error(17, fileIo->path_, pf, strError());
}
std::remove(fileIo->path_.c_str());
// Check permissions of new file
struct stat buf2;
- if (statOk && ::stat(path_.c_str(), &buf2) == -1) {
+ if (statOk && ::stat(pf, &buf2) == -1) {
statOk = false;
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, path_, strError(), "stat") << "
";
+ std::cerr << "Warning: " << Error(2, pf, strError(), "stat") << "
";
#endif
}
if (statOk && buf1.st_mode != buf2.st_mode) {
// Set original file permissions
- if (::chmod(path_.c_str(), buf1.st_mode) == -1) {
+ if (::chmod(pf, buf1.st_mode) == -1) {
#ifndef SUPPRESS_WARNINGS
- std::cerr << "Warning: " << Error(2, path_, strError(), "chmod") << "
";
+ std::cerr << "Warning: " << Error(2, pf, strError(), "chmod") << "
";
#endif
}
}
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list