BurgerLib
Public Member Functions | Public Attributes | Private Attributes
Burger::DirectorySearch Class Reference

Directory contents iteration class. More...

#include <fmfile.h>

Collaboration diagram for Burger::DirectorySearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DirectorySearch ()
 Initialize a Burger::DirectorySearch class.
 ~DirectorySearch ()
 Closes any open directory.
Word Open (const char *pDirName)
 Open a directory for scanning.
Word GetNextEntry (void)
 Iterate on a directory and return the next found filename.
Word GetNextEntryExtension (const char *pExt)
 Iterate on a directory and return the next found filename.that matches a specific file extension.
void Close (void)
 Closes any open directory.

Public Attributes

WordPtr m_uFileSize
 Size of the file in bytes (64 bits on 64 bit CPU platforms)
Burger::TimeDate_t m_CreationDate
 File creation time.
Burger::TimeDate_t m_ModificatonDate
 File last modification time.
Word8 m_bDir
 True if this is a directory.
Word8 m_bSystem
 True if this is a system file.
Word8 m_bHidden
 True if this file is hidden.
Word8 m_bLocked
 True if this file is read only.
char m_Name [256]
 Filename.
Word32 m_uFileType
 File's type (MacOS Only)
Word32 m_uAuxType
 File's creator code (MacOS Only)

Private Attributes

OpaqueFSIterator * m_pIterator
 Directory iterator (MacOS Carbon Only)
voidm_pEnumerator
 Filename enumerator (MacOSX Only)
char * m_pPathPrefix
 Pathname buffer (MacOSX Only)
char * m_pPathEnd
 Pathname ending (MacOSX Only)
Word m_bHandleOk
 Handle is valid (MSDOS Only)
short m_sFileHandle
 Handle to the open directory (MSDOS Only)
char m_MyFindT [44]
 Dos FindT structure (MSDOS Only)
voidm_hDirHandle
 Win95 file handle (Windows Only)
char m_MyFindW [592]
 Win95 WIN32_FIND_DATAW structure (Windows Only)

Detailed Description

Directory contents iteration class.

To open and traverse a directory is this classes' main purpose. Given a BurgerLib formatted pathname, open the directory and iterate over it until all the names of the files contained are presented to the application for use.

Using it is very simple...

    Burger::DirectorySearch MyDir;
    // Open the directory for traversal
    Word uError = MyDir.Open("9:Directory");
    if (!uError) {      // No error?
        while (!MyDir.GetNextEntry()) {
            printf("Found \"%s\"!\n",MyDir.m_Name);
        }
        MyDir.Close();
    }
See also:
struct Burger::FileManager
Note:
All filenames are encoded using UTF8! Do not assume native encoding

Constructor & Destructor Documentation

Initialize a Burger::DirectorySearch class.

Simple initialization function.

See also:
Burger::DirectorySearch::Open(const char *)

Closes any open directory.

See also:
Burger::DirectorySearch::Close(void)

Member Function Documentation

Closes any open directory.

See also:
Burger::DirectorySearch::~DirectorySearch(void)

Iterate on a directory and return the next found filename.

Reads the current directory opened previously by a call to Burger::DirectorySearch::Open(const char *) and initializes all of the internal public variables with information of the file that was found.

Returns:
Zero on success, non-zero on an error or if the directory wasn't opened or if the end of the directory was reached
See also:
Burger::DirectorySearch::Close(void) or Burger::DirectorySearch::GetNextEntryExtension(const char *)

Iterate on a directory and return the next found filename.that matches a specific file extension.

Reads the current directory opened previously by a call to Burger::DirectorySearch::Open(const char *) and initializes all of the internal public variables with information of the file that was found.

This differs from Burger::DirectorySearch::GetNextEntry(void) in that only files that end with a specific file extension are returned. This is a case insensitive search.

    while (!MyDir.GetNextEntryExtension("txt")) {
        printf("Found text file \"%s\"!\n",MyDir.m_Name);
    }
Parameters:
pExtPointer to a "C" string of the file extension being scanned for.
Returns:
Zero on success, non-zero on an error or if the directory wasn't opened or if the end of the directory was reached
See also:
Burger::DirectorySearch::Close(void) or Burger::DirectorySearch::GetNextEntry(void)
Note:
Only filenames are returned. All directory filenames are skipped, even if their names match the extension.
Word Burger::DirectorySearch::Open ( const char *  pDirName)

Open a directory for scanning.

Parameters:
pDirNamePointer to the "C" string filename in BurgerLib format.
Returns:
Zero on success, non-zero on an error or if the directory doesn't exist
See also:
Burger::DirectorySearch::Close(void) or Burger::DirectorySearch::GetNextEntry(void)

Member Data Documentation

True if this is a directory.

Handle is valid (MSDOS Only)

True if this file is hidden.

True if this file is read only.

True if this is a system file.

File creation time.

Win95 file handle (Windows Only)

File last modification time.

Dos FindT structure (MSDOS Only)

Win95 WIN32_FIND_DATAW structure (Windows Only)

Filename enumerator (MacOSX Only)

OpaqueFSIterator* Burger::DirectorySearch::m_pIterator [private]

Directory iterator (MacOS Carbon Only)

Pathname ending (MacOSX Only)

Pathname buffer (MacOSX Only)

Handle to the open directory (MSDOS Only)

File's creator code (MacOS Only)

Size of the file in bytes (64 bits on 64 bit CPU platforms)

File's type (MacOS Only)