FileFind Struct Reference


Public Methods

struct FileFind* FileFind_ctor (struct FileFind *ptr_file_find, struct File *ptr_file_info, char *sz_mask)
bool FileFind_has_more_elements (struct FileFind *ptr_file_find)
void FileFind_init (struct FileFind *ptr_file_find, struct File *ptr_file_info, char *sz_mask)
struct File* FileFind_next_element (struct FileFind *ptr_file_find)
void FileFind_dtor (struct FileFind *ptr_file_find, int memory_flag)


Detailed Description

Implements the functions needed to find a set of files.

See also:
File I/O


Member Function Documentation

struct FileFind * FileFind_ctor ( struct FileFind * ptr_file_find,
struct File * ptr_file_info,
char * sz_mask )

Starts a new search session using a specified search mask.

Parameters:
ptr_file_find A pointer to the FileFind structure
ptr_file_info A pointer the initialized File object to store the result
sz_mask File search mask (symbols '*' and '?' supported)
Returns:
A pointer to the initialized FileFind object
 #include <cybiko.h>
 ...
 struct FileFind searcher;
 struct File file_info;
 ...
 File_ctor( &file_info );
 FileFind_ctor( &searcher, &file_info, "quake.*" );
 ...
 TRACE( "Search results:" );
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 File_dtor( &file_info , LEAVE_MEMORY );
 FileFind_dtor( &searcher, LEAVE_MEMORY );
 ...

void FileFind_dtor ( struct FileFind * ptr_file_find,
int memory_flag )

Deletes an object.

Parameters:
ptr_file_find A pointer to the initialized FileFind object
memory_flag Can be FREE_MEMORY or LEAVE_MEMORY. If the memory was allocated for the object by malloc(), use FREE_MEMORY to free it. Use LEAVE_MEMORY If the object was static or allocated in a stack
Returns:
None.
 #include <cybiko.h>
 ...
 struct FileFind searcher;
 struct File file_info;
 ...
 FileFind_ctor( &searcher, &file_info, "quake.*" );
 File_ctor( &file_info );
 ...
 TRACE( "Search results:");
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 File_dtor( &file_info, LEAVE_MEMORY );
 FileFind_dtor( &searcher , LEAVE_MEMORY );
 ...
See also:
FREE_MEMORY, LEAVE_MEMORY.

bool FileFind_has_more_elements ( struct FileFind * ptr_file_find )

Checks wheter there are any elements left in the search.

Parameters:
ptr_file_find A pointer to the initialized FileFind object
Returns:
TRUE if there are any elements left in the search, otherwise FALSE
 #include <cybiko.h>
 ...
 struct FileFind searcher;
 struct File file_info;
 ...
 File_ctor( &file_info );
 FileFind_ctor( &searcher, &file_info, "quake.*" );
 ...
 TRACE("Search results:");
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 File_dtor( &file_info , LEAVE_MEMORY );
 FileFind_dtor( &searcher, LEAVE_MEMORY );
 ...

void FileFind_init ( struct FileFind * ptr_file_find,
struct File * ptr_file_info,
char * sz_mask )

Initializes the new file search session.

Parameters:
ptr_file_find A pointer to the initialized FileFind object
ptr_file_info A pointer to the initialized File object to store the result
sz_mask File search mask (symbols '*' and '?' supported).
Returns:
None.
 #include <cybiko.h>
 ...
 struct FileFind searcher;
 struct File file_info;
 ...
 File_ctor( &file_info );
 FileFind_ctor( &searcher, &file_info, "quake.*" );
 ...
 TRACE( "Search results for quake :" );
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 FileFind_init( &searcher, &file_info, "warcraft.*" );
 TRACE( "Search results for warcraft :" );
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 File_dtor( &file_info , LEAVE_MEMORY );
 FileFind_dtor( &searcher, LEAVE_MEMORY );
 ...

struct File * FileFind_next_element ( struct FileFind * ptr_file_find )

Retrieves the next element of the file search session.

Parameters:
ptr_file_find A pointer to the initialized FileFind object
Returns:
File's address, or NULL if there are no more elements
 #include <cybiko.h>
 ...
 struct FileFind searcher;
 struct File file_info;
 ...
 FileFind_ctor( &searcher, &file_info, "quake.*" );
 ...
 TRACE( "Search results:" );
 do
 {
 FileFind_next_element( &searcher );
 TRACE( "\t%s has size %ld", file_info.name, file_info.size );
 }while( FileFind_has_more_elements( &searcher ) );
 ...
 File_dtor( &file_info , LEAVE_MEMORY );
 FileFind_dtor( &searcher, LEAVE_MEMORY );
 ...


Copyright © 2001 Cybiko, Inc. All rights reserved. | More information...

AltStyle によって変換されたページ (->オリジナル) /