Inviwo  0.9.10.1
Inviwo documentation
inviwo::TinyDirInterface Class Reference

#include <tinydirinterface.h>

Public Types

enum  ListMode { FilesOnly, DirectoriesOnly, FilesAndDirectories }
 

Public Member Functions

 TinyDirInterface (TinyDirInterface const &)=delete
 
TinyDirInterfaceoperator= (TinyDirInterface const &)=delete
 
bool open (const std::string &path)
 Opens the given path as directory resource. More...
 
void close ()
 Closes any open directory resource. Directory contents can no longer be listed. The resource will automatically be closed on deconstruction of this object. More...
 
bool isOpen () const
 Returns whether a directory resource is open, i.e. available, for querying. More...
 
void setListMode (ListMode mode)
 Set the current mode used for listing the directory. More...
 
ListMode getListMode () const
 Returns the current mode used for listing the directory. More...
 
bool isNextEntryAvailable () const
 Returns whether the directory resource can be queried for another entry. More...
 
std::string getNextEntry ()
 Queries the directory for the next entry. The current ListMode determines what contents will be returned. An empty string is returned in case the resource is closed or no further file is available. Querying the last file automatically closes the directory resource. More...
 
std::string getNextEntryWithBasePath ()
 Convenience function for getNextEntry including the base path. More...
 
std::vector< std::string > getContents ()
 Queries the directory for all entries. The current ListMode determines what contents will be returned. An empty vector is returned in case the resource is closed. This function will close the directory resource. More...
 
std::vector< std::string > getContentsWithBasePath ()
 Convenience function for getContents including the base path. More...
 

Protected Member Functions

std::string getNextEntry (bool includeBasePath)
 

Detailed Description

Interface for tinydir responsible for listing files in a directory. Depending on the list mode (default ListMode::FilesOnly), the result contains files, directories or both.

Member Function Documentation

◆ close()

void inviwo::TinyDirInterface::close ( )

Closes any open directory resource. Directory contents can no longer be listed. The resource will automatically be closed on deconstruction of this object.

See also
open

◆ getContents()

std::vector< std::string > inviwo::TinyDirInterface::getContents ( )

Queries the directory for all entries. The current ListMode determines what contents will be returned. An empty vector is returned in case the resource is closed. This function will close the directory resource.

See also
close getNextEntry getFileNamesWithBasePath
Returns
directory listing based on ListMode setting.
Exceptions
FileException

◆ getContentsWithBasePath()

std::vector< std::string > inviwo::TinyDirInterface::getContentsWithBasePath ( )

Convenience function for getContents including the base path.

See also
close getNextEntry getContents
Returns
directory listing based on ListMode setting.
Exceptions
FileException

◆ getListMode()

TinyDirInterface::ListMode inviwo::TinyDirInterface::getListMode ( ) const

Returns the current mode used for listing the directory.

Returns
current listing mode

◆ getNextEntry()

std::string inviwo::TinyDirInterface::getNextEntry ( )

Queries the directory for the next entry. The current ListMode determines what contents will be returned. An empty string is returned in case the resource is closed or no further file is available. Querying the last file automatically closes the directory resource.

See also
close getNextEntryWithBasePath
Returns
next entry in directory. If none is available or the directory was not open before, an empty string is returned.
Exceptions
FileException

◆ getNextEntryWithBasePath()

std::string inviwo::TinyDirInterface::getNextEntryWithBasePath ( )

Convenience function for getNextEntry including the base path.

See also
close getNextEntry
Returns
next entry in directory. If none is available or the directory was not open before, an empty string is returned.
Exceptions
FileException

◆ isNextEntryAvailable()

bool inviwo::TinyDirInterface::isNextEntryAvailable ( ) const

Returns whether the directory resource can be queried for another entry.

Returns
True if directory listing contains at least one entry.

◆ isOpen()

bool inviwo::TinyDirInterface::isOpen ( ) const

Returns whether a directory resource is open, i.e. available, for querying.

Returns
True if resource is open. False otherwise.

◆ open()

bool inviwo::TinyDirInterface::open ( const std::string &  path)

Opens the given path as directory resource.

See also
close isOpen
Parameters
pathPath of the directory whose contents will be queried.
Returns
True if opening the directory resource is successful.

◆ setListMode()

void inviwo::TinyDirInterface::setListMode ( ListMode  mode)

Set the current mode used for listing the directory.

Parameters
modenew listing mode

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