|
|
@ -1430,12 +1430,12 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
|
|
void XPathIo::ReadStdin() {
|
|
|
|
void XPathIo::ReadStdin() {
|
|
|
|
if (isatty(fileno(stdin)))
|
|
|
|
if (isatty(fileno(stdin)))
|
|
|
|
throw Error(kerInvalidIccProfile);
|
|
|
|
throw Error(kerInputDataReadFailed);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _O_BINARY
|
|
|
|
#ifdef _O_BINARY
|
|
|
|
// convert stdin to binary
|
|
|
|
// convert stdin to binary
|
|
|
|
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
|
|
|
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
|
|
|
throw Error(kerInvalidXMP);
|
|
|
|
throw Error(kerInputDataReadFailed);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
char readBuf[100*1024];
|
|
|
|
char readBuf[100*1024];
|
|
|
@ -1511,16 +1511,16 @@ namespace Exiv2 {
|
|
|
|
std::stringstream ss;
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << timestamp << XPathIo::TEMP_FILE_EXT;
|
|
|
|
ss << timestamp << XPathIo::TEMP_FILE_EXT;
|
|
|
|
std::string path = ss.str();
|
|
|
|
std::string path = ss.str();
|
|
|
|
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prot == pStdin) {
|
|
|
|
if (prot == pStdin) {
|
|
|
|
if (isatty(fileno(stdin)))
|
|
|
|
if (isatty(fileno(stdin)))
|
|
|
|
throw Error(kerInvalidIccProfile);
|
|
|
|
throw Error(kerInputDataReadFailed);
|
|
|
|
#if defined(_MSC_VER) || defined(__MINGW__)
|
|
|
|
#if defined(_MSC_VER) || defined(__MINGW__)
|
|
|
|
// convert stdin to binary
|
|
|
|
// convert stdin to binary
|
|
|
|
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
|
|
|
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
|
|
|
throw Error(kerInvalidXMP);
|
|
|
|
throw Error(kerInputDataReadFailed);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
|
|
|
|
// read stdin and write to the temp file.
|
|
|
|
// read stdin and write to the temp file.
|
|
|
|
char readBuf[100*1024];
|
|
|
|
char readBuf[100*1024];
|
|
|
|
std::streamsize readBufSize = 0;
|
|
|
|
std::streamsize readBufSize = 0;
|
|
|
@ -1531,23 +1531,29 @@ namespace Exiv2 {
|
|
|
|
fs.write (readBuf, readBufSize);
|
|
|
|
fs.write (readBuf, readBufSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(readBufSize);
|
|
|
|
} while(readBufSize);
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
} else if (prot == pDataUri) {
|
|
|
|
} else if (prot == pDataUri) {
|
|
|
|
|
|
|
|
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
|
|
|
|
// read data uri and write to the temp file.
|
|
|
|
// read data uri and write to the temp file.
|
|
|
|
size_t base64Pos = orgPath.find("base64,");
|
|
|
|
size_t base64Pos = orgPath.find("base64,");
|
|
|
|
if (base64Pos == std::string::npos)
|
|
|
|
if (base64Pos == std::string::npos) {
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
throw Error(kerErrorMessage, "No base64 data");
|
|
|
|
throw Error(kerErrorMessage, "No base64 data");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string data = orgPath.substr(base64Pos+7);
|
|
|
|
std::string data = orgPath.substr(base64Pos+7);
|
|
|
|
char* decodeData = new char[data.length()];
|
|
|
|
char* decodeData = new char[data.length()];
|
|
|
|
long size = base64decode(data.c_str(), decodeData, data.length());
|
|
|
|
long size = base64decode(data.c_str(), decodeData, data.length());
|
|
|
|
if (size > 0)
|
|
|
|
if (size > 0) {
|
|
|
|
fs.write(decodeData, size);
|
|
|
|
fs.write(decodeData, size);
|
|
|
|
else
|
|
|
|
fs.close();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
throw Error(kerErrorMessage, "Unable to decode base 64.");
|
|
|
|
throw Error(kerErrorMessage, "Unable to decode base 64.");
|
|
|
|
|
|
|
|
}
|
|
|
|
delete[] decodeData;
|
|
|
|
delete[] decodeData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fs.close();
|
|
|
|
|
|
|
|
return path;
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|