libsqsh v1.5.2
Loading...
Searching...
No Matches
SqshDirectoryIterator Struct Reference

A directory iterator. More...

#include <sqsh_directory_private.h>

Public Member Functions

SQSH_NO_UNUSED struct SqshDirectoryIteratorsqsh_directory_iterator_new (const struct SqshFile *file, int *err)
 Allocates and initializes a new directory iterator.
 
SQSH_NO_UNUSED bool sqsh_directory_iterator_next (struct SqshDirectoryIterator *iterator, int *err)
 Advances the iterator to the next entry.
 
SQSH_NO_UNUSED int sqsh_directory_iterator_lookup (struct SqshDirectoryIterator *iterator, const char *name, const size_t name_len)
 Looks up an entry by name.
 
uint16_t sqsh_directory_iterator_name_size (const struct SqshDirectoryIterator *iterator)
 Retrieves the size of the name of the current entry.
 
uint32_t sqsh_directory_iterator_inode (const struct SqshDirectoryIterator *iterator)
 Retrieves the inode number of the current entry.
 
uint64_t sqsh_directory_iterator_inode_number (const struct SqshDirectoryIterator *iterator)
 Retrieves the inode number of the current entry.
 
uint64_t sqsh_directory_iterator_inode_ref (const struct SqshDirectoryIterator *iterator)
 Retrieves the inode reference of the current entry.
 
enum SqshFileType sqsh_directory_iterator_file_type (const struct SqshDirectoryIterator *iterator)
 Retrieves the inode type of the current entry.
 
SQSH_NO_UNUSED struct SqshFilesqsh_directory_iterator_open_file (const struct SqshDirectoryIterator *iterator, int *err)
 Loads the inode of the current entry.
 
const char * sqsh_directory_iterator_name2 (const struct SqshDirectoryIterator *iterator, size_t *len)
 Retrieves the name of the current entry.
 
const char * sqsh_directory_iterator_name (const struct SqshDirectoryIterator *iterator)
 Retrieves the name of the current entry.
 
SQSH_NO_UNUSED char * sqsh_directory_iterator_name_dup (const struct SqshDirectoryIterator *iterator)
 creates a heap allocated copy of the name of the current entry.
 
int sqsh_directory_iterator_free (struct SqshDirectoryIterator *iterator)
 Frees the resources used by a directory iterator.
 

Detailed Description

A directory iterator.

Definition at line 53 of file sqsh_directory_private.h.

Member Function Documentation

◆ sqsh_directory_iterator_file_type()

enum SqshFileType sqsh_directory_iterator_file_type ( const struct SqshDirectoryIterator * iterator)

Retrieves the inode type of the current entry.

Parameters
[in]iteratorThe iterator to use.
Returns
The inode type on success, SQSH_INODE_TYPE_UNKNOWN on error.

◆ sqsh_directory_iterator_free()

int sqsh_directory_iterator_free ( struct SqshDirectoryIterator * iterator)

Frees the resources used by a directory iterator.

Parameters
[in]iteratorThe iterator to free.
Returns
The file name of the current directory entry, NULL if the allocation fails. The user is responsible for freeing the memory.

◆ sqsh_directory_iterator_inode()

uint32_t sqsh_directory_iterator_inode ( const struct SqshDirectoryIterator * iterator)

Retrieves the inode number of the current entry.

Parameters
[in]iteratorThe iterator to use.
Returns
The inode number.

◆ sqsh_directory_iterator_inode_number()

uint64_t sqsh_directory_iterator_inode_number ( const struct SqshDirectoryIterator * iterator)

Retrieves the inode number of the current entry.

Deprecated
Since 1.2.0. Use sqsh_directory_iterator_inode() instead.
Parameters
[in]iteratorThe iterator to use.
Returns
The inode number.

◆ sqsh_directory_iterator_inode_ref()

uint64_t sqsh_directory_iterator_inode_ref ( const struct SqshDirectoryIterator * iterator)

Retrieves the inode reference of the current entry.

Parameters
[in]iteratorThe iterator to use.
Returns
The inode reference.

◆ sqsh_directory_iterator_lookup()

SQSH_NO_UNUSED int sqsh_directory_iterator_lookup ( struct SqshDirectoryIterator * iterator,
const char * name,
const size_t name_len )

Looks up an entry by name.

Parameters
[in,out]iteratorThe iterator to use.
[in]nameThe name of the entry to look up.
[in]name_lenThe length of the name.
Returns
0 on success, a negative value on error.

◆ sqsh_directory_iterator_name()

const char * sqsh_directory_iterator_name ( const struct SqshDirectoryIterator * iterator)

Retrieves the name of the current entry.

Deprecated
Since 1.3.0. Use sqsh_directory_iterator_name2() instead.

The returned pointer is allocated internally and only valid until the next call of sqsh_directory_iterator_next(). It must not be freed. The returned string is not 0 terminated. Use sqsh_directory_iterator_name_size() to get the size of the value.

Parameters
[in]iteratorThe iterator to use.
Returns
The name of the current entry.

◆ sqsh_directory_iterator_name2()

const char * sqsh_directory_iterator_name2 ( const struct SqshDirectoryIterator * iterator,
size_t * len )

Retrieves the name of the current entry.

The returned pointer is allocated internally and only valid until the next call of sqsh_directory_iterator_next(). It must not be freed. The returned string is not 0 terminated.

Parameters
[in]iteratorThe iterator to use.
[out]lenPointer to a size_t where the length of the name will be stored.
Returns
The name of the current entry.

◆ sqsh_directory_iterator_name_dup()

SQSH_NO_UNUSED char * sqsh_directory_iterator_name_dup ( const struct SqshDirectoryIterator * iterator)

creates a heap allocated copy of the name of the current entry.

The caller is responsible for calling free() on the returned pointer.

The returned string is 0 terminated.

Parameters
[in]iteratorThe iterator to use.
Returns
The name of the current entry.

◆ sqsh_directory_iterator_name_size()

uint16_t sqsh_directory_iterator_name_size ( const struct SqshDirectoryIterator * iterator)

Retrieves the size of the name of the current entry.

Deprecated
Since 1.3.0. Use sqsh_directory_iterator_name2() instead.
Parameters
[in]iteratorThe iterator to use.
Returns
The size of the name on success, a negative value on error.

◆ sqsh_directory_iterator_new()

SQSH_NO_UNUSED struct SqshDirectoryIterator * sqsh_directory_iterator_new ( const struct SqshFile * file,
int * err )

Allocates and initializes a new directory iterator.

Parameters
[in]filefile context of a directory to iterate over.
[out]errPointer to an int where the error code will be stored.
Returns
The new iterator on success, NULL on error.

◆ sqsh_directory_iterator_next()

SQSH_NO_UNUSED bool sqsh_directory_iterator_next ( struct SqshDirectoryIterator * iterator,
int * err )

Advances the iterator to the next entry.

Parameters
[in,out]iteratorThe iterator to advance.
[out]errPointer to an int where the error code will be stored.
Return values
trueWhen the iterator has been advanced
falseWhen the iterator has reached the end of the directory or if an error occured.

◆ sqsh_directory_iterator_open_file()

SQSH_NO_UNUSED struct SqshFile * sqsh_directory_iterator_open_file ( const struct SqshDirectoryIterator * iterator,
int * err )

Loads the inode of the current entry.

Parameters
[in]iteratorThe iterator to use.
[out]errPointer to an int where the error code will be stored.
Returns
The loaded inode on success, NULL on error.

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