diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2019-08-17 22:36:37 +0200 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2019-08-19 18:56:58 +0200 |
| commit | f40a21f5a6ca674d93905269bcb4b21f92c41800 (patch) | |
| tree | 79eb145e8828fdd2131f2a1251bc1f9133cedabc /src/cc4group.h | |
| parent | 9f6da4965422b9f32c6a92b03b662bde025cc72c (diff) | |
| download | cc4group-f40a21f5a6ca674d93905269bcb4b21f92c41800.tar.gz cc4group-f40a21f5a6ca674d93905269bcb4b21f92c41800.zip | |
Add cc4group.addFromDisk with according cc4group.AllowEntryTypes
Diffstat (limited to 'src/cc4group.h')
| -rw-r--r-- | src/cc4group.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/cc4group.h b/src/cc4group.h index c8ff6f6..d2d978c 100644 --- a/src/cc4group.h +++ b/src/cc4group.h @@ -11,9 +11,9 @@ // just keep in mind that it may return NULL in the rare case that memory allocation fails for whatever reason // - after creating a fresh CC4Group object it's intended use needs to be decided on, by either calling cc4group.create on it... // ...to create an empty group in-memory where contents may be added later -// or call cc4group.openExisting together with the path to a physical group file on disk to load it's contents into memory +// or call cc4group.openExisting together with the path to a physical group file (or normal folder) on disk to load it's contents into memory // (for more sophisticated cases, one of the other open functions may be used) -// it is important that only one of this function is called only on freshly created groups +// it is important that only one of these functions is called only on freshly created groups // otherwise in the lucky case some assertion may trigger or other undefined things may happen // this two step process is needed to ensure informational error reporting when something goes wrong while opening existing groups // - after calling cc4group.create or some cc4group.open-function, the group can be inspected and modified to your heart's content through the rest of the available API @@ -177,6 +177,13 @@ typedef bool (*CC4Group_WriteCallback)(const void* const data, size_t const size // it contains all available methods and constants typedef struct { struct { + int File; // only a single regular file is allowed + int Directory; // only a directory is allowed, contents are handled recursively + int All; // currently File | Directory + } const AllowedEntryTypes; + + + struct { CC4Group_MemoryManagement Take; // cc4group will free the data when its not needed anymore; e.g. in the destructor or when setting the file's data again CC4Group_MemoryManagement Copy; // cc4group will copy the data to use it; the original data is untouched and needs to be freed by the caller whenever desired CC4Group_MemoryManagement Reference; // cc4group will use the data as is (i.e. store the pointer and use it); the caller must guarantee it's validity throughout the groups lifetime (or until the file's data is set to a new pointer) and needs to take care of freeing it afterwards @@ -226,7 +233,7 @@ typedef struct { // initializes the group to be a fresh, empty group bool (*create)(CC4Group* const this); - // opens a group on the filesystem; path may point to a directory inside a group; path "-" can be used to read the group from stdin + // opens a group or a normal folder on the filesystem; path may point to a directory inside a group; path "-" can be used to read the group from stdin bool (*openExisting)(CC4Group* const this, const char* const path); // opens a group that is stored entirely in memory @@ -338,6 +345,14 @@ typedef struct { // modifying the group + // adds (also only in-memory until saving) a file or folder as is on disk + // be careful, the contents are not stored in memory, files and folders are accessed in the same strategy as the lazy-mode works (on first demand, then cached) + // thus, later modifications may result in inconsistent states if saving is delayed for long + // targetEntryPath denotes full path where the entry should be stored, including its filename + // allowedEntryTypes tells cc4group what type of entries it should expect. unexpected types will produce an error + // see the definition of AllowedEntryTypes for details + bool (*addFromDisk)(CC4Group* const this, const char* const path, const char* const targetEntryPath, int const allowedEntryTypes); + // creates an empty directory inside the group at the place with the name as denoted by path // the parent directory (if any) must exist alredy bool (*createDirectory)(CC4Group* const this, const char* const path); |
