Design Pattern Examples
Overview of object-oriented design patterns
Composite_FileDirEntry.c File Reference

Implementation of the FileDirEntry_GetFileDirType(), FileDirEntry_GetLength(), FileDirEntry_GetChildren(), FileDirEntry_GetName(), and FileDirEntry_GetWhenModified() functions as used in support of the Composite Pattern example. More...

Include dependency graph for Composite_FileDirEntry.c:

Go to the source code of this file.

Functions

FileDirTypes FileDirEntry_GetFileDirType (FileDirEntry *entry)
 Get the type of this FileDirEntry object as a value from the FileDirTypes enumeration.
 
long FileDirEntry_GetLength (FileDirEntry *entry)
 Get the length of the given FileDirEntry object. For Files, this is a static value. For Directories, this is computed once from all the children of the directory and stored internally.
 
FileDirEntryFileDirEntry_GetChildren (FileDirEntry *entry)
 Retrieve a pointer to the first child of the given FileDirEntry object. If the entry does not support children or the entry has no children, returns a NULL pointer.
 
const char * FileDirEntry_GetName (FileDirEntry *entry)
 Retrieve the name of the given FileDirEntry object.
 
time_t FileDirEntry_GetWhenModified (FileDirEntry *entry)
 Retrieve the last modified time of the given FileDirEntry object.
 

Detailed Description

Function Documentation

◆ FileDirEntry_GetChildren()

FileDirEntry * FileDirEntry_GetChildren ( FileDirEntry entry)

Retrieve a pointer to the first child of the given FileDirEntry object. If the entry does not support children or the entry has no children, returns a NULL pointer.

Parameters
entryA FileDirEntry object to examine.
Returns
Returns a FileDirEntry* representing the first child in the list; Returns NULL if there are no children or the FileDirEntry object is a FileEntry object that does not support children.

Definition at line 62 of file Composite_FileDirEntry.c.

References DirEntry::_children, FileDirEntry::fileDirType, and FileDirType_Directory.

Referenced by _FindEntry(), and Composite_Exercise_FormatEntry().

◆ FileDirEntry_GetFileDirType()

FileDirTypes FileDirEntry_GetFileDirType ( FileDirEntry entry)

Get the type of this FileDirEntry object as a value from the FileDirTypes enumeration.

Parameters
entryA FileDirEntry object to examine.
Returns
Returns a value from the FileDirTypes enumeration indicating the type of the object.

Definition at line 13 of file Composite_FileDirEntry.c.

References FileDirEntry::fileDirType, and FileDirType_Unknown.

Referenced by Composite_Exercise_FormatEntry().

◆ FileDirEntry_GetLength()

long FileDirEntry_GetLength ( FileDirEntry entry)

Get the length of the given FileDirEntry object. For Files, this is a static value. For Directories, this is computed once from all the children of the directory and stored internally.

Parameters
entryA FileEntry or DirEntry object for which to get the length.
Returns
Returns the length of the given entry.

Definition at line 28 of file Composite_FileDirEntry.c.

References DirEntry::_children, DirEntry::_lengthSet, DirEntry::base, FileDirEntry_GetLength(), FileDirEntry::fileDirType, FileDirType_Directory, FileDirType_File, FileDirEntry::length, and FileDirEntry::next.

Referenced by Composite_Exercise_FormatEntry(), and FileDirEntry_GetLength().

◆ FileDirEntry_GetName()

const char * FileDirEntry_GetName ( FileDirEntry entry)

Retrieve the name of the given FileDirEntry object.

Parameters
entryFileDirEntry object to examine.
Returns
Returns a pointer to the name of the entry.

Definition at line 81 of file Composite_FileDirEntry.c.

References FileDirEntry::name.

Referenced by _FindEntry(), and Composite_Exercise_FormatEntry().

◆ FileDirEntry_GetWhenModified()

time_t FileDirEntry_GetWhenModified ( FileDirEntry entry)

Retrieve the last modified time of the given FileDirEntry object.

Parameters
entryFileDirEntry object to examine.
Returns
Returns a time_t value representing last modified time of the FileDirEntry object.

Definition at line 96 of file Composite_FileDirEntry.c.

References FileDirEntry::whenModified.

Referenced by Composite_Exercise_FormatEntry().