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 /examples | |
| parent | 9f6da4965422b9f32c6a92b03b662bde025cc72c (diff) | |
| download | cc4group-f40a21f5a6ca674d93905269bcb4b21f92c41800.tar.gz cc4group-f40a21f5a6ca674d93905269bcb4b21f92c41800.zip | |
Add cc4group.addFromDisk with according cc4group.AllowEntryTypes
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/c4add.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/c4add.c b/examples/c4add.c new file mode 100644 index 0000000..2fa7e82 --- /dev/null +++ b/examples/c4add.c @@ -0,0 +1,42 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "cc4group.h" + +int main(int argc, char* argv[]) +{ + if(argc != 3 && argc != 4) + { + fprintf(stderr, "USAGE: %s <group> <file|directory> [target path]\n", argv[0]); + return EXIT_FAILURE; + } + + CC4Group* group = cc4group.new(); + bool success = cc4group.openExisting(group, argv[1]); + if(!success) + { + fprintf(stderr, "ERROR: Can not open group file \"%s\": %s\n", argv[1], cc4group.getErrorMessage(group)); + } + else + { + success = cc4group.addFromDisk(group, argv[2], argc == 4 ? argv[3] : argv[2], cc4group.AllowedEntryTypes.All); + + if(!success) + { + fprintf(stderr, "ERROR: Can not add file/directory \"%s\" from disk: %s\n", argv[2], cc4group.getErrorMessage(group)); + } + else + { + success = cc4group.saveOverwrite(group, argv[1]); + + if(!success) + { + fprintf(stderr, "ERROR: Can not save group file \"%s\": %s\n", argv[2], cc4group.getErrorMessage(group)); + } + } + } + cc4group.delete(group); + + return success ? EXIT_SUCCESS : EXIT_FAILURE; +} |
