lfilesystem  0.0.1
C++ filesystem library
limes::files::Volume Class Referencefinal

This class represents a logical filesystem volume. More...

#include <lfilesystem_Volume.h>

Public Types

enum class  Type {
  CDRom , HardDisk , Removable , Network ,
  RAM , Unknown
}
 Represents the type of a filesystem volume. More...
 

Public Member Functions

 Volume (const Path &path=dirs::cwd().getAbsolutePath())
 Creates a Volume object representing the volume that the passed path exists on. More...
 
std::uintmax_t bytesFree () const
 Returns the number of available bytes on this volume. More...
 
bool contains (const FilesystemEntry &file) const noexcept
 Returns true if this volume contains the passed FilesystemEntry. More...
 
std::string getLabel () const
 Returns this volume's label. More...
 
Path getPath () const noexcept
 Returns the root path of this volume. More...
 
int getSerialNumber () const
 Returns this volume's serial number. More...
 
Type getType () const
 Returns the type of this volume. More...
 
bool isCaseSensitive () const
 Returns true if paths on this volume are case-sensitive. More...
 
bool isReadOnly () const
 Returns true if this volume is read-only. More...
 
std::uintmax_t totalBytes () const
 Returns the total size of this volume in bytes. More...
 
Equality comparison

Compares the root paths of two volumes for equality.

bool operator== (const Volume &other) const noexcept
 
bool operator!= (const Volume &other) const noexcept
 

Static Public Member Functions

static std::vector< VolumegetAll () noexcept
 Returns all currently mounted volumes. More...
 
static std::optional< VolumetryCreate (const Path &path=dirs::cwd().getAbsolutePath()) noexcept
 A noexcept method for creating a volume object. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const Volume &value)
 Writes the Volume object's path to the output stream. More...
 

Detailed Description

This class represents a logical filesystem volume.

You can construct a Volume object from any path, and the resulting Volume object will refer to the logical volume where the passed path was mounted at the time of the Volume object's construction.

Todo:

ConstructionError custom exception type? This could allow more specific error checking. The error could contain the original passed path.

supportsHardLinks()?

Definition at line 58 of file lfilesystem_Volume.h.

Member Enumeration Documentation

◆ Type

Represents the type of a filesystem volume.

Enumerator
CDRom 

Indicates this volume is a CD.

HardDisk 

Indicates this volume is on the computer's hard disk.

Removable 

Indicates this volume is a removable drive, such as a USB drive, etc.

Network 

Indicates this volume is a remote/network drive.

RAM 

Indicates this volume is a RAM drive.

Unknown 

The type of this volume cannot be determined.

Definition at line 131 of file lfilesystem_Volume.h.

Constructor & Destructor Documentation

◆ Volume()

limes::files::Volume::Volume ( const Path path = dirs::cwd().getAbsolutePath())
explicit

Creates a Volume object representing the volume that the passed path exists on.

Exceptions
std::runtime_errorAn exception will be thrown if the volume cannot be determined for the passed path.
See also
tryCreate()

Member Function Documentation

◆ bytesFree()

std::uintmax_t limes::files::Volume::bytesFree ( ) const

Returns the number of available bytes on this volume.

See also
volume::bytesFree()

◆ contains()

bool limes::files::Volume::contains ( const FilesystemEntry file) const
noexcept

Returns true if this volume contains the passed FilesystemEntry.

If the volume of the passed FilesystemEntry cannot be determined, this function will return false by default.

◆ getAll()

static std::vector<Volume> limes::files::Volume::getAll ( )
staticnoexcept

Returns all currently mounted volumes.

Currently mounted volumes are rescanned every time you call this function.

◆ getLabel()

std::string limes::files::Volume::getLabel ( ) const

Returns this volume's label.

This will always return an empty string on iOS/watchOS/tvOS.

See also
volume::label()
Todo:
test coverage

◆ getPath()

Path limes::files::Volume::getPath ( ) const
noexcept

Returns the root path of this volume.

On Windows, this might be a drive letter such as C:\ or D:\ ; on Linux this might be something like /media/usb/drive-1/ .

◆ getSerialNumber()

int limes::files::Volume::getSerialNumber ( ) const

Returns this volume's serial number.

If the serial number cannot be retrieved, this will return 0. This will always return 0 on Apple systems. Note than on Linux systems, this may fail (and return 0) if the calling process does not have root privileges.

See also
volume::serialNumber()
Todo:
test coverage

◆ getType()

Type limes::files::Volume::getType ( ) const

Returns the type of this volume.

See also
volume::type()
Todo:
Linux: detect RAM type
Todo:
Mac: detect RAM & Network types

◆ isCaseSensitive()

bool limes::files::Volume::isCaseSensitive ( ) const

Returns true if paths on this volume are case-sensitive.

See also
volume::caseSensitive()

◆ isReadOnly()

bool limes::files::Volume::isReadOnly ( ) const

Returns true if this volume is read-only.

See also
volume::readOnly()

◆ operator!=()

bool limes::files::Volume::operator!= ( const Volume other) const
noexcept
Todo:
test coverage

◆ operator==()

bool limes::files::Volume::operator== ( const Volume other) const
noexcept
Todo:
test coverage

◆ totalBytes()

std::uintmax_t limes::files::Volume::totalBytes ( ) const

Returns the total size of this volume in bytes.

See also
volume::totalBytes()

◆ tryCreate()

static std::optional<Volume> limes::files::Volume::tryCreate ( const Path path = dirs::cwd().getAbsolutePath())
staticnoexcept

A noexcept method for creating a volume object.

This will return a null optional if the volume cannot be correctly determined for the passed path.


The documentation for this class was generated from the following file: