Design Pattern Examples
Overview of object-oriented design patterns
c/Composite_FileDirEntry.h
Go to the documentation of this file.
1
7
8#pragma once
9#ifndef __FILEDIRENTRY_H__
10#define __FILEDIRENTRY_H__
11
12#include <stdbool.h>
13#include <time.h>
14
19typedef enum
20{
25
30
36
37
43typedef struct FileDirEntry
44{
51
56 const char* name;
57
62 long length;
63
69
76
77
83typedef struct
84{
86} FileEntry;
87
88
98typedef struct
99{
104} DirEntry;
105
114
124
135
141const char* FileDirEntry_GetName(FileDirEntry* entry);
142
150
151#endif // __FILEDIRENTRY_H__
152
const char * FileDirEntry_GetName(FileDirEntry *entry)
Retrieve the name of the given FileDirEntry object.
long FileDirEntry_GetLength(FileDirEntry *entry)
Get the length of the given FileDirEntry object. For Files, this is a static value....
FileDirTypes
Represents the type of entries allowed in the hierarchy for the Composite design pattern example.
@ FileDirType_Directory
Represents a directory entry that can contain other FileDirEntry components.
@ FileDirType_File
Represents a file entry.
@ FileDirType_Unknown
Represents an unknown type and is considered an error condition.
FileDirTypes FileDirEntry_GetFileDirType(FileDirEntry *entry)
Get the type of this FileDirEntry object as a value from the FileDirTypes enumeration.
FileDirEntry * FileDirEntry_GetChildren(FileDirEntry *entry)
Retrieve a pointer to the first child of the given FileDirEntry object. If the entry does not support...
time_t FileDirEntry_GetWhenModified(FileDirEntry *entry)
Retrieve the last modified time of the given FileDirEntry object.
Represents a Directory entry.
FileDirEntry * _children
Linked list of possible children. NULL if empty.
bool _lengthSet
FileDirEntry base
Base FileDirEntry identifying this entry.
Structure representing a File (FileEntry) or Directory (DirEntry) entry. This is included as the firs...
FileDirTypes fileDirType
Value from the FileDirTypes enumeration indicating what type of entry this is a part of....
const char * name
Name of this entry. Use the FileDirEntry_GetName() function to get this value.
struct FileDirEntry * next
Points to the next entry in a linked list of FileDirEntry objects. NULL means no more in list.
long length
Length of this entry. For DirEntry objects, this is computed when getting the length by calling the F...
time_t whenModified
Timestamp of when this entry was last "modified". Use the FileDirEntry_GetWhenModified() function to ...
Represents a File entry.
FileDirEntry base
Base FileDirEntry identifying this entry.