diff options
author | Alberto <alberto.ruiz@codethink.co.uk> | 2011-09-29 17:06:57 +0100 |
---|---|---|
committer | Alberto <alberto.ruiz@codethink.co.uk> | 2011-09-29 17:06:57 +0100 |
commit | a0315ddfa3bf687043f8a23de7f4487e7076191b (patch) | |
tree | 7cd14fba51ddf14e86ec9059129c2c8a2755edfd /otap_create.c | |
parent | 9d291afa5d3b0c3b7c9dce3d8fd2c1f25d3dbd1e (diff) | |
download | tbdiff-a0315ddfa3bf687043f8a23de7f4487e7076191b.tar.gz |
Taking into account recursive directory creation. Code cleanups.
Diffstat (limited to 'otap_create.c')
-rw-r--r-- | otap_create.c | 85 |
1 files changed, 47 insertions, 38 deletions
diff --git a/otap_create.c b/otap_create.c index a977adf..74df635 100644 --- a/otap_create.c +++ b/otap_create.c @@ -422,44 +422,6 @@ _otap_create_cmd_entity_delete (FILE *stream, } static int -_otap_create_dir(FILE *stream, - otap_stat_t *d) -{ - int err; - if(((err =_otap_create_cmd_dir_create(stream, d)) != 0) - || ((err = _otap_create_cmd_dir_enter(stream, d->name)) != 0)) - return err; - - uintptr_t i; - for(i = 0; i < d->size; i++) - { - otap_stat_t* f = otap_stat_entry(d, i); - - if(f == NULL) - otap_error(OTAP_ERROR_UNABLE_TO_STAT_FILE); - - switch(f->type) - { - case OTAP_STAT_TYPE_FILE: - err = _otap_create_cmd_file_create(stream, f); - break; - case OTAP_STAT_TYPE_DIR: - err = _otap_create_dir(stream, f); - break; - default: - otap_stat_free(f); - otap_error(OTAP_ERROR_FEATURE_NOT_IMPLEMENTED); - break; - } - otap_stat_free(f); - if(err != 0) - return err; - } - - return _otap_create_cmd_dir_leave(stream, 1); -} - -static int _otap_create_cmd_dir_delta (FILE *stream, otap_stat_t *a, otap_stat_t *b) @@ -588,6 +550,53 @@ _otap_create_cmd_special_delta(FILE *stream, } static int +_otap_create_dir(FILE *stream, + otap_stat_t *d) +{ + int err; + if(((err =_otap_create_cmd_dir_create(stream, d)) != 0) + || ((err = _otap_create_cmd_dir_enter(stream, d->name)) != 0)) + return err; + + uintptr_t i; + for(i = 0; i < d->size; i++) + { + otap_stat_t* f = otap_stat_entry(d, i); + + if(f == NULL) + otap_error(OTAP_ERROR_UNABLE_TO_STAT_FILE); + + switch(f->type) + { + case OTAP_STAT_TYPE_FILE: + err = _otap_create_cmd_file_create(stream, f); + break; + case OTAP_STAT_TYPE_DIR: + err = _otap_create_dir(stream, f); + break; + case OTAP_STAT_TYPE_SYMLINK: + err = _otap_create_cmd_symlink_create(stream, f); + break; + case OTAP_STAT_TYPE_BLKDEV: + case OTAP_STAT_TYPE_CHRDEV: + case OTAP_STAT_TYPE_FIFO: + case OTAP_STAT_TYPE_SOCKET: + err = _otap_create_cmd_special_create(stream, f); + break; + default: + otap_stat_free(f); + otap_error(OTAP_ERROR_FEATURE_NOT_IMPLEMENTED); + break; + } + otap_stat_free(f); + if(err != 0) + return err; + } + + return _otap_create_cmd_dir_leave(stream, 1); +} + +static int _otap_create (FILE *stream, otap_stat_t *a, otap_stat_t *b, |