Declaration of the FileDirEntry, FileEntry, DirEntry structures, along with the FileDirEntry_GetFileDirType(), FileDirEntry_GetLength(), FileDirEntry_GetChildren(), FileDirEntry_GetName(), and FileDirEntry_GetWhenModified() functions as used in support of the Composite Pattern example. More...
#include <stdbool.h>
#include <time.h>
Go to the source code of this file.
Classes | |
struct | FileDirEntry |
Structure representing a File (FileEntry) or Directory (DirEntry) entry. This is included as the first element of FileEntry and DirEntry structures. It allows those structures to be cast as a FileDirEntry*. More... | |
struct | FileEntry |
Represents a File entry. More... | |
struct | DirEntry |
Represents a Directory entry. More... | |
Macros | |
#define | __FILEDIRENTRY_H__ |
Typedefs | |
typedef struct FileDirEntry | FileDirEntry |
Structure representing a File (FileEntry) or Directory (DirEntry) entry. This is included as the first element of FileEntry and DirEntry structures. It allows those structures to be cast as a FileDirEntry*. | |
Enumerations | |
enum | FileDirTypes { FileDirType_File , FileDirType_Directory , FileDirType_Unknown = -1 } |
Represents the type of entries allowed in the hierarchy for the Composite design pattern example. More... | |
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. | |
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. | |
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. | |
Declaration of the FileDirEntry, FileEntry, DirEntry structures, along with the FileDirEntry_GetFileDirType(), FileDirEntry_GetLength(), FileDirEntry_GetChildren(), FileDirEntry_GetName(), and FileDirEntry_GetWhenModified() functions as used in support of the Composite Pattern example.
Definition in file c/Composite_FileDirEntry.h.
#define __FILEDIRENTRY_H__ |
Definition at line 10 of file c/Composite_FileDirEntry.h.
typedef struct FileDirEntry FileDirEntry |
enum FileDirTypes |
Represents the type of entries allowed in the hierarchy for the Composite design pattern example.
Enumerator | |
---|---|
FileDirType_File | Represents a file entry. |
FileDirType_Directory | Represents a directory entry that can contain other FileDirEntry components. |
FileDirType_Unknown | Represents an unknown type and is considered an error condition. |
Definition at line 19 of file c/Composite_FileDirEntry.h.
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.
entry | A FileDirEntry object to examine. |
Definition at line 62 of file Composite_FileDirEntry.c.
References DirEntry::_children, FileDirEntry::fileDirType, and FileDirType_Directory.
Referenced by _FindEntry(), and Composite_Exercise_FormatEntry().
FileDirTypes FileDirEntry_GetFileDirType | ( | FileDirEntry * | entry | ) |
Get the type of this FileDirEntry object as a value from the FileDirTypes enumeration.
entry | A FileDirEntry object to examine. |
Definition at line 13 of file Composite_FileDirEntry.c.
References FileDirEntry::fileDirType, and FileDirType_Unknown.
Referenced by Composite_Exercise_FormatEntry().
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.
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().
const char * FileDirEntry_GetName | ( | FileDirEntry * | entry | ) |
Retrieve the name of the given FileDirEntry object.
entry | FileDirEntry object to examine. |
Definition at line 81 of file Composite_FileDirEntry.c.
References FileDirEntry::name.
Referenced by _FindEntry(), and Composite_Exercise_FormatEntry().
time_t FileDirEntry_GetWhenModified | ( | FileDirEntry * | entry | ) |
Retrieve the last modified time of the given FileDirEntry object.
entry | FileDirEntry object to examine. |
Definition at line 96 of file Composite_FileDirEntry.c.
References FileDirEntry::whenModified.
Referenced by Composite_Exercise_FormatEntry().