mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-21 02:00:33 +01:00
Merge remote-tracking branch 'pocoproj@github/develop' into PostgreSQLonTravisAndAppVeyor
This commit is contained in:
commit
690104595d
@ -197,7 +197,11 @@ void SQLiteStatementImpl::bindImpl()
|
||||
if (boundRowCount != (*_bindBegin)->numOfRowsHandled())
|
||||
throw BindingException("Size mismatch in Bindings. All Bindings MUST have the same size");
|
||||
|
||||
(*_bindBegin)->bind(pos);
|
||||
std::size_t namedBindPos = 0;
|
||||
if (!(*_bindBegin)->name().empty())
|
||||
namedBindPos = (std::size_t)sqlite3_bind_parameter_index(_pStmt, (*_bindBegin)->name().c_str());
|
||||
|
||||
(*_bindBegin)->bind((namedBindPos != 0) ? namedBindPos : pos);
|
||||
pos += (*_bindBegin)->numOfColumnsHandled();
|
||||
}
|
||||
|
||||
|
@ -208,6 +208,15 @@ public:
|
||||
/// Fills the vector with the names of all
|
||||
/// files in the directory.
|
||||
|
||||
FileSize totalSpace() const;
|
||||
/// Returns the total size in bytes of the partition containing this path.
|
||||
|
||||
FileSize usableSpace() const;
|
||||
/// Returns the number of usable free bytes on the partition containing this path.
|
||||
|
||||
FileSize freeSpace() const;
|
||||
/// Returns the number of free bytes on the partition containing this path.
|
||||
|
||||
bool operator == (const File& file) const;
|
||||
bool operator != (const File& file) const;
|
||||
bool operator < (const File& file) const;
|
||||
|
@ -58,6 +58,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -59,6 +59,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastError(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -58,6 +58,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -59,6 +59,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -59,6 +59,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -59,6 +59,9 @@ protected:
|
||||
void removeImpl();
|
||||
bool createFileImpl();
|
||||
bool createDirectoryImpl();
|
||||
FileSizeImpl totalSpaceImpl() const;
|
||||
FileSizeImpl usableSpaceImpl() const;
|
||||
FileSizeImpl freeSpaceImpl() const;
|
||||
static void handleLastErrorImpl(const std::string& path);
|
||||
|
||||
private:
|
||||
|
@ -316,6 +316,24 @@ void File::list(std::vector<std::string>& files) const
|
||||
}
|
||||
|
||||
|
||||
File::FileSize File::totalSpace() const
|
||||
{
|
||||
return totalSpaceImpl();
|
||||
}
|
||||
|
||||
|
||||
File::FileSize File::usableSpace() const
|
||||
{
|
||||
return usableSpaceImpl();
|
||||
}
|
||||
|
||||
|
||||
File::FileSize File::freeSpace() const
|
||||
{
|
||||
return freeSpaceImpl();
|
||||
}
|
||||
|
||||
|
||||
void File::list(std::vector<File>& files) const
|
||||
{
|
||||
files.clear();
|
||||
|
@ -20,6 +20,12 @@
|
||||
#include <algorithm>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(POCO_OS_FAMILY_BSD)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
@ -408,6 +414,42 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (errno)
|
||||
|
@ -350,6 +350,36 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
// TODO: implement
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (errno)
|
||||
|
@ -330,6 +330,42 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_blocks * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_bavail * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
struct statfs stats;
|
||||
if (statfs(_path.c_str(), &stats) != 0)
|
||||
handleLastErrorImpl(_path);
|
||||
|
||||
return (FileSizeImpl)stats.f_bfree * (FileSizeImpl)stats.f_bsize;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (errno)
|
||||
|
@ -349,6 +349,39 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceEx(_path.c_str(), NULL, &space, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceEx(_path.c_str(), &space, NULL, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceEx(_path.c_str(), NULL, NULL, &space))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
|
@ -357,6 +357,39 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
|
@ -348,6 +348,39 @@ bool FileImpl::createDirectoryImpl()
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::totalSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, &space, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::usableSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), &space, NULL, NULL))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
FileImpl::FileSizeImpl FileImpl::freeSpaceImpl() const
|
||||
{
|
||||
poco_assert(!_path.empty());
|
||||
|
||||
ULARGE_INTEGER space;
|
||||
if (!GetDiskFreeSpaceExW(_upath.c_str(), NULL, NULL, &space))
|
||||
handleLastErrorImpl(_path);
|
||||
return space.QuadPart;
|
||||
}
|
||||
|
||||
|
||||
void FileImpl::handleLastErrorImpl(const std::string& path)
|
||||
{
|
||||
switch (GetLastError())
|
||||
|
@ -180,6 +180,33 @@ void FileTest::testFileAttributes1()
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
f.totalSpace();
|
||||
failmsg("file does not exist - must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
f.usableSpace();
|
||||
failmsg("file does not exist - must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
f.freeSpace();
|
||||
failmsg("file does not exist - must throw exception");
|
||||
}
|
||||
catch (Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -317,6 +344,15 @@ void FileTest::testSize()
|
||||
}
|
||||
|
||||
|
||||
void FileTest::testSpace()
|
||||
{
|
||||
File f(Path::home());
|
||||
assert(f.totalSpace() > 0);
|
||||
assert(f.usableSpace() > 0);
|
||||
assert(f.freeSpace() > 0);
|
||||
}
|
||||
|
||||
|
||||
void FileTest::testDirectory()
|
||||
{
|
||||
File d("testdir");
|
||||
@ -525,6 +561,7 @@ CppUnit::Test* FileTest::suite()
|
||||
CppUnit_addTest(pSuite, FileTest, testCompare);
|
||||
CppUnit_addTest(pSuite, FileTest, testSwap);
|
||||
CppUnit_addTest(pSuite, FileTest, testSize);
|
||||
CppUnit_addTest(pSuite, FileTest, testSpace);
|
||||
CppUnit_addTest(pSuite, FileTest, testDirectory);
|
||||
CppUnit_addTest(pSuite, FileTest, testCopy);
|
||||
CppUnit_addTest(pSuite, FileTest, testMove);
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void testCompare();
|
||||
void testSwap();
|
||||
void testSize();
|
||||
void testSpace();
|
||||
void testDirectory();
|
||||
void testCopy();
|
||||
void testMove();
|
||||
|
@ -115,33 +115,43 @@ void TCPServer::run()
|
||||
while (!_stopped)
|
||||
{
|
||||
Poco::Timespan timeout(250000);
|
||||
if (_socket.poll(timeout, Socket::SELECT_READ))
|
||||
try
|
||||
{
|
||||
try
|
||||
if (_socket.poll(timeout, Socket::SELECT_READ))
|
||||
{
|
||||
StreamSocket ss = _socket.acceptConnection();
|
||||
// enable nodelay per default: OSX really needs that
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
if (ss.address().family() != AddressFamily::UNIX_LOCAL)
|
||||
#endif
|
||||
try
|
||||
{
|
||||
ss.setNoDelay(true);
|
||||
StreamSocket ss = _socket.acceptConnection();
|
||||
// enable nodelay per default: OSX really needs that
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
if (ss.address().family() != AddressFamily::UNIX_LOCAL)
|
||||
#endif
|
||||
{
|
||||
ss.setNoDelay(true);
|
||||
}
|
||||
_pDispatcher->enqueue(ss);
|
||||
}
|
||||
catch (Poco::Exception& exc)
|
||||
{
|
||||
ErrorHandler::handle(exc);
|
||||
}
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
ErrorHandler::handle(exc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ErrorHandler::handle();
|
||||
}
|
||||
_pDispatcher->enqueue(ss);
|
||||
}
|
||||
catch (Poco::Exception& exc)
|
||||
{
|
||||
ErrorHandler::handle(exc);
|
||||
}
|
||||
catch (std::exception& exc)
|
||||
{
|
||||
ErrorHandler::handle(exc);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ErrorHandler::handle();
|
||||
}
|
||||
}
|
||||
catch (Poco::Exception& exc)
|
||||
{
|
||||
ErrorHandler::handle(exc);
|
||||
// possibly a resource issue since poll() failed;
|
||||
// give some time to recover before trying again
|
||||
Poco::Thread::sleep(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,13 @@
|
||||
set(LIBNAME "XML")
|
||||
set(POCO_LIBNAME "Poco${LIBNAME}")
|
||||
|
||||
# Expat CPP sources to be excluded from globbed SRCS_G
|
||||
# They are added back on the list if POCO_UNBUNDLED is not set
|
||||
set(EXPAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/xmlparse.cpp")
|
||||
|
||||
# Sources
|
||||
file(GLOB SRCS_G "src/*.cpp")
|
||||
list(REMOVE_ITEM SRCS_G ${EXPAT_CPP})
|
||||
POCO_SOURCES_AUTO( SRCS ${SRCS_G})
|
||||
|
||||
# Headers
|
||||
|
Loading…
x
Reference in New Issue
Block a user