Rhino C++ API  8.4
Public Member Functions | List of all members
ON_FileIterator Class Reference

#include <opennurbs_file_utilities.h>

Public Member Functions

 ON_FileIterator ()=default
 ~ON_FileIterator ()
ON__UINT64 CurrentItemCount () const
const ON_wString CurrentItemFullPathName () const
bool CurrentItemIsDirectory () const
bool CurrentItemIsFile () const
bool CurrentItemIsHidden () const
ON__UINT64 CurrentItemLastModifiedTime () const
const ON_wString CurrentItemName () const
ON__UINT64 CurrentItemSize () const
const ON_wString DirectoryName () const
bool FirstItem ()
bool Initialize (const char *directory_name)
bool Initialize (const char *directory_name, const char *item_name_filter)
bool Initialize (const wchar_t *directory_name)
bool Initialize (const wchar_t *directory_name, const wchar_t *item_name_filter)
bool NextItem ()
void Reset ()

Detailed Description

Description: Iterates through every item in a file system directory.

Constructor & Destructor Documentation

◆ ON_FileIterator()

ON_FileIterator::ON_FileIterator ( )

◆ ~ON_FileIterator()

ON_FileIterator::~ON_FileIterator ( )

Member Function Documentation

◆ CurrentItemCount()

ON__UINT64 ON_FileIterator::CurrentItemCount ( ) const

Returns: Number of matching items iterated through.

◆ CurrentItemFullPathName()

const ON_wString ON_FileIterator::CurrentItemFullPathName ( ) const

◆ CurrentItemIsDirectory()

bool ON_FileIterator::CurrentItemIsDirectory ( ) const

Returns true if the current item is a directory.

◆ CurrentItemIsFile()

bool ON_FileIterator::CurrentItemIsFile ( ) const

Returns true if the current item is a file.

◆ CurrentItemIsHidden()

bool ON_FileIterator::CurrentItemIsHidden ( ) const

Returns true if the current file or directory is hidden. This means its name begins with a '.' or it's Windows hidden attribute is true.

◆ CurrentItemLastModifiedTime()

ON__UINT64 ON_FileIterator::CurrentItemLastModifiedTime ( ) const

Returns: File last modified time in seconds since January 1, 1970 Remarks: The times returned by ON_FileIterator can differ from the time returned by ON_FileStream::GetFileInformation().

◆ CurrentItemName()

const ON_wString ON_FileIterator::CurrentItemName ( ) const

Current item query Returns: Current file or directory name in the directory being iterated. Use CurrentFullPathItemName() to get the full path name.

◆ CurrentItemSize()

ON__UINT64 ON_FileIterator::CurrentItemSize ( ) const

Returns: If the current item is a file, then the size of the file in bytes is returned. If the current item is a directory, then 0 is returned.

◆ DirectoryName()

const ON_wString ON_FileIterator::DirectoryName ( ) const

Returns: The name of the directory being iterated.

◆ FirstItem()

bool ON_FileIterator::FirstItem ( )

Iteratation iteration tools Description: Find the first matching item in the directory. Example: / Iterate through the files in a directory named "\rootdir\subdir" ON_FileIterator fit; fit.Initialize("\\rootdir\\subdir"); for ( bool bHaveItem = fit.FirstItem(); bHaveItem; bHaveItem = fit.NextItem() ) { if ( fit.CurrentFileIsDirectory() ) continue; ON_String fullpath = fit.CurrentItemFullPathName(); FILE* fp = ON_FileStream::Open(fullpath,"rb"); if ( 0 == fp ) { continue; } ... ON_FileStream::Close(fp); fp = 0; } }

Returns: true: The iterator is set to the first item. false: There are no matching items.

◆ Initialize() [1/4]

bool ON_FileIterator::Initialize ( const char *  directory_name)

◆ Initialize() [2/4]

bool ON_FileIterator::Initialize ( const char *  directory_name,
const char *  item_name_filter 

◆ Initialize() [3/4]

bool ON_FileIterator::Initialize ( const wchar_t *  directory_name)

Iteratation initialization tools Description: Initialize where the search should occur. Parameters: directory_name - [in] The directory to look in. item_name_filter - [in] If this parameter is null, then the iteration includes all names in the directory. The item name to search for. This parameter can include wildcard characters, such as an asterisk (*) or a question mark (?). For example, "\rootdir\subdir\*.*" will iterate all files in the \rootdir\subdir\ directory.

Returns: true: The iterator is set to the first item. false: There are no matching items.

Remarks: Calling FirstItem() is equivalent to calling Initialize() and then calling NextItem().

◆ Initialize() [4/4]

bool ON_FileIterator::Initialize ( const wchar_t *  directory_name,
const wchar_t *  item_name_filter 

◆ NextItem()

bool ON_FileIterator::NextItem ( )

Description: Find the next matching item in the directory. Returns: true: The iterator was advanced to the next item. false: There are no more matching items.

◆ Reset()

void ON_FileIterator::Reset ( )

Description: Reset this ON_FileIterator so it can be used again.