|
|
|
@ -35,6 +35,7 @@
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef EXV_ENABLE_FILESYSTEM
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
@ -47,19 +48,7 @@ namespace fs = std::filesystem;
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
|
// class member definitions
|
|
|
|
|
namespace {
|
|
|
|
|
/// @brief replace each substring of the subject that matches the given search string with the given replacement.
|
|
|
|
|
void ReplaceStringInPlace(std::string& subject, std::string_view search, std::string_view replace) {
|
|
|
|
|
auto pos = subject.find(search);
|
|
|
|
|
while (pos != std::string::npos) {
|
|
|
|
|
subject.replace(pos, search.length(), replace);
|
|
|
|
|
pos += subject.find(search, pos + replace.length());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // namespace
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace Exiv2 {
|
|
|
|
|
void BasicIo::readOrThrow(byte* buf, size_t rcount, ErrorCode err) {
|
|
|
|
@ -73,6 +62,7 @@ void BasicIo::seekOrThrow(int64_t offset, Position pos, ErrorCode err) {
|
|
|
|
|
Internal::enforce(r == 0, err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef EXV_ENABLE_FILESYSTEM
|
|
|
|
|
//! Internal Pimpl structure of class FileIo.
|
|
|
|
|
class FileIo::Impl {
|
|
|
|
|
public:
|
|
|
|
@ -550,6 +540,7 @@ const std::string& FileIo::path() const noexcept {
|
|
|
|
|
|
|
|
|
|
void FileIo::populateFakeData() {
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//! Internal Pimpl structure of class MemIo.
|
|
|
|
|
class MemIo::Impl final {
|
|
|
|
@ -898,7 +889,7 @@ void XPathIo::ReadDataUri(const std::string& path) {
|
|
|
|
|
delete[] decodeData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
#elif defined(EXV_ENABLE_FILESYSTEM)
|
|
|
|
|
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), tempFilePath_(path()) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -913,6 +904,16 @@ void XPathIo::transfer(BasicIo& src) {
|
|
|
|
|
if (isTemp_) {
|
|
|
|
|
// replace temp path to gent path.
|
|
|
|
|
auto currentPath = path();
|
|
|
|
|
|
|
|
|
|
// replace each substring of the subject that matches the given search string with the given replacement.
|
|
|
|
|
auto ReplaceStringInPlace = [](std::string& subject, std::string_view search, std::string_view replace) {
|
|
|
|
|
auto pos = subject.find(search);
|
|
|
|
|
while (pos != std::string::npos) {
|
|
|
|
|
subject.replace(pos, search.length(), replace);
|
|
|
|
|
pos += subject.find(search, pos + replace.length());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ReplaceStringInPlace(currentPath, XPathIo::TEMP_FILE_EXT, XPathIo::GEN_FILE_EXT);
|
|
|
|
|
setPath(currentPath);
|
|
|
|
|
|
|
|
|
@ -1707,7 +1708,7 @@ CurlIo::CurlIo(const std::string& url, size_t blockSize) {
|
|
|
|
|
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
// free functions
|
|
|
|
|
|
|
|
|
|
#ifdef EXV_ENABLE_FILESYSTEM
|
|
|
|
|
DataBuf readFile(const std::string& path) {
|
|
|
|
|
FileIo file(path);
|
|
|
|
|
if (file.open("rb") != 0) {
|
|
|
|
@ -1727,6 +1728,7 @@ size_t writeFile(const DataBuf& buf, const std::string& path) {
|
|
|
|
|
}
|
|
|
|
|
return file.write(buf.c_data(), buf.size());
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef EXV_USE_CURL
|
|
|
|
|
size_t curlWriter(char* data, size_t size, size_t nmemb, std::string* writerData) {
|
|
|
|
|