fix895-ICCProfile-FalseWarning
This commit is contained in:
parent
5a3afa9cbe
commit
ab0b97c729
@ -1430,12 +1430,12 @@ namespace Exiv2 {
|
||||
|
||||
void XPathIo::ReadStdin() {
|
||||
if (isatty(fileno(stdin)))
|
||||
throw Error(kerInvalidIccProfile);
|
||||
throw Error(kerInputDataReadFailed);
|
||||
|
||||
#ifdef _O_BINARY
|
||||
// convert stdin to binary
|
||||
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
||||
throw Error(kerInvalidXMP);
|
||||
throw Error(kerInputDataReadFailed);
|
||||
#endif
|
||||
|
||||
char readBuf[100*1024];
|
||||
@ -1511,16 +1511,16 @@ namespace Exiv2 {
|
||||
std::stringstream ss;
|
||||
ss << timestamp << XPathIo::TEMP_FILE_EXT;
|
||||
std::string path = ss.str();
|
||||
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
|
||||
if (prot == pStdin) {
|
||||
if (isatty(fileno(stdin)))
|
||||
throw Error(kerInvalidIccProfile);
|
||||
throw Error(kerInputDataReadFailed);
|
||||
#if defined(_MSC_VER) || defined(__MINGW__)
|
||||
// convert stdin to binary
|
||||
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
||||
throw Error(kerInvalidXMP);
|
||||
throw Error(kerInputDataReadFailed);
|
||||
#endif
|
||||
std::ofstream fs(path.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
// read stdin and write to the temp file.
|
||||
char readBuf[100*1024];
|
||||
std::streamsize readBufSize = 0;
|
||||
@ -1531,23 +1531,29 @@ namespace Exiv2 {
|
||||
fs.write (readBuf, readBufSize);
|
||||
}
|
||||
} while(readBufSize);
|
||||
fs.close();
|
||||
} 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.
|
||||
size_t base64Pos = orgPath.find("base64,");
|
||||
if (base64Pos == std::string::npos)
|
||||
if (base64Pos == std::string::npos) {
|
||||
fs.close();
|
||||
throw Error(kerErrorMessage, "No base64 data");
|
||||
}
|
||||
|
||||
std::string data = orgPath.substr(base64Pos+7);
|
||||
char* decodeData = new char[data.length()];
|
||||
long size = base64decode(data.c_str(), decodeData, data.length());
|
||||
if (size > 0)
|
||||
if (size > 0) {
|
||||
fs.write(decodeData, size);
|
||||
else
|
||||
fs.close();
|
||||
} else {
|
||||
fs.close();
|
||||
throw Error(kerErrorMessage, "Unable to decode base 64.");
|
||||
}
|
||||
delete[] decodeData;
|
||||
}
|
||||
|
||||
fs.close();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@ -259,19 +259,22 @@ namespace Exiv2 {
|
||||
struct {
|
||||
std::string name ;
|
||||
Protocol prot ;
|
||||
bool url ; // path.size() > name.size()
|
||||
} prots[] =
|
||||
{ { "http://" ,pHttp }
|
||||
, { "https://" ,pHttps }
|
||||
, { "ftp://" ,pFtp }
|
||||
, { "sftp://" ,pSftp }
|
||||
, { "ssh://" ,pSsh }
|
||||
, { "file://" ,pFileUri }
|
||||
, { "data://" ,pDataUri }
|
||||
, { "-" ,pStdin }
|
||||
{ { "http://" ,pHttp , true }
|
||||
, { "https://" ,pHttps , true }
|
||||
, { "ftp://" ,pFtp , true }
|
||||
, { "sftp://" ,pSftp , true }
|
||||
, { "ssh://" ,pSsh , true }
|
||||
, { "file://" ,pFileUri , true }
|
||||
, { "data://" ,pDataUri , true }
|
||||
, { "-" ,pStdin , false }
|
||||
};
|
||||
for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
|
||||
if ( path.find(prots[i].name) == 0 )
|
||||
result = prots[i].prot;
|
||||
// URL's require data. Stdin == "-" and no further data
|
||||
if ( prots[i].url ? path.size() > prots[i].name.size() : path.size() == prots[i].name.size() )
|
||||
result = prots[i].prot;
|
||||
|
||||
return result;
|
||||
} // fileProtocol
|
||||
@ -281,19 +284,22 @@ namespace Exiv2 {
|
||||
struct {
|
||||
std::wstring wname ;
|
||||
Protocol prot ;
|
||||
bool url ; // path.size() > name.size()
|
||||
} prots[] =
|
||||
{ { L"http://" ,pHttp }
|
||||
, { L"https://" ,pHttps }
|
||||
, { L"ftp://" ,pFtp }
|
||||
, { L"sftp://" ,pSftp }
|
||||
, { L"ssh://" ,pSsh }
|
||||
, { L"file://" ,pFileUri }
|
||||
, { L"data://" ,pDataUri }
|
||||
, { L"-" ,pStdin }
|
||||
{ { L"http://" ,pHttp , true }
|
||||
, { L"https://" ,pHttps , true }
|
||||
, { L"ftp://" ,pFtp , true }
|
||||
, { L"sftp://" ,pSftp , true }
|
||||
, { L"ssh://" ,pSsh , true }
|
||||
, { L"file://" ,pFileUri , true }
|
||||
, { L"data://" ,pDataUri , true }
|
||||
, { L"-" ,pStdin , false }
|
||||
};
|
||||
for ( size_t i = 0 ; result == pFile && i < sizeof(prots)/sizeof(prots[0]) ; i ++ )
|
||||
if ( wpath.find(prots[i].wname) == 0 )
|
||||
result = prots[i].prot;
|
||||
if ( path.find(prots[i].name) == 0 )
|
||||
// URL's require data. Stdin == "-" and no further data
|
||||
if ( prots[i].url ? path.size() > prots[i].name.size() : path.size() == prots[i].name.size() )
|
||||
result = prots[i].prot;
|
||||
|
||||
return result;
|
||||
} // fileProtocol
|
||||
|
||||
Loading…
Reference in New Issue
Block a user