mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
Add partition space information to File class
Add File::totalSpaceImpl(), File::usableSpaceImpl() and File::freeSpaceImpl() to retrieve total, available and usable space in the filesystem for the specified path.
This commit is contained in:
committed by
Tobias Taschner
parent
59b5b4e46e
commit
9972496811
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user