Merge remote-tracking branch 'origin/poco-1.8.0' into poco-1.8.0

This commit is contained in:
zosrothko 2017-11-01 09:02:13 +01:00
commit 57befa2bdc
2 changed files with 27 additions and 17 deletions

View File

@ -206,7 +206,7 @@ Timestamp FileImpl::createdImpl() const
struct stat st;
if (stat(_path.c_str(), &st) == 0)
return Timestamp::fromEpochTime(st.st_ctime);
#endif
#endif
else
handleLastErrorImpl(_path);
return 0;
@ -265,7 +265,7 @@ void FileImpl::setWriteableImpl(bool flag)
poco_assert (!_path.empty());
struct stat st;
if (stat(_path.c_str(), &st) != 0)
if (stat(_path.c_str(), &st) != 0)
handleLastErrorImpl(_path);
mode_t mode;
if (flag)
@ -277,7 +277,7 @@ void FileImpl::setWriteableImpl(bool flag)
mode_t wmask = S_IWUSR | S_IWGRP | S_IWOTH;
mode = st.st_mode & ~wmask;
}
if (chmod(_path.c_str(), mode) != 0)
if (chmod(_path.c_str(), mode) != 0)
handleLastErrorImpl(_path);
}
@ -287,19 +287,23 @@ void FileImpl::setExecutableImpl(bool flag)
poco_assert (!_path.empty());
struct stat st;
if (stat(_path.c_str(), &st) != 0)
if (stat(_path.c_str(), &st) != 0)
handleLastErrorImpl(_path);
mode_t mode;
if (flag)
{
mode = st.st_mode | S_IXUSR;
if (st.st_mode & S_IRGRP)
mode |= S_IXGRP;
if (st.st_mode & S_IROTH)
mode |= S_IXOTH;
}
else
{
mode_t wmask = S_IXUSR | S_IXGRP | S_IXOTH;
mode = st.st_mode & ~wmask;
}
if (chmod(_path.c_str(), mode) != 0)
if (chmod(_path.c_str(), mode) != 0)
handleLastErrorImpl(_path);
}
@ -312,7 +316,7 @@ void FileImpl::copyToImpl(const std::string& path) const
if (sd == -1) handleLastErrorImpl(_path);
struct stat st;
if (fstat(sd, &st) != 0)
if (fstat(sd, &st) != 0)
{
close(sd);
handleLastErrorImpl(_path);
@ -331,7 +335,7 @@ void FileImpl::copyToImpl(const std::string& path) const
int n;
while ((n = read(sd, buffer.begin(), blockSize)) > 0)
{
if (write(dd, buffer.begin(), n) != n)
if (write(dd, buffer.begin(), n) != n)
handleLastErrorImpl(path);
}
if (n < 0)
@ -344,7 +348,7 @@ void FileImpl::copyToImpl(const std::string& path) const
throw;
}
close(sd);
if (fsync(dd) != 0)
if (fsync(dd) != 0)
{
close(dd);
handleLastErrorImpl(path);
@ -379,7 +383,7 @@ void FileImpl::removeImpl()
bool FileImpl::createFileImpl()
{
poco_assert (!_path.empty());
int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (n != -1)
{
@ -400,7 +404,7 @@ bool FileImpl::createDirectoryImpl()
if (existsImpl() && isDirectoryImpl())
return false;
if (mkdir(_path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0)
if (mkdir(_path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) != 0)
handleLastErrorImpl(_path);
return true;
}

View File

@ -222,8 +222,8 @@ void Base64Test::testDecoderURL()
assert (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("AAECAw==", Poco::BASE64_URL_ENCODING);
Base64Decoder decoder(istr);
std::istringstream istr("AAECAw==");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
assert (decoder.good() && decoder.get() == 0);
assert (decoder.good() && decoder.get() == 1);
assert (decoder.good() && decoder.get() == 2);
@ -231,8 +231,8 @@ void Base64Test::testDecoderURL()
assert (decoder.good() && decoder.get() == -1);
}
{
std::istringstream istr("QUJDREVG", Poco::BASE64_URL_ENCODING);
Base64Decoder decoder(istr);
std::istringstream istr("QUJDREVG");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
std::string s;
decoder >> s;
assert (s == "ABCDEF");
@ -242,9 +242,15 @@ void Base64Test::testDecoderURL()
{
std::istringstream istr("QUJ\r\nDRE\r\nVG");
Base64Decoder decoder(istr, Poco::BASE64_URL_ENCODING);
std::string s;
decoder >> s;
assert (decoder.bad());
try
{
std::string s;
decoder >> s;
assert (decoder.bad());
}
catch (DataFormatException&)
{
}
}
{
std::istringstream istr("QUJD#REVG");