summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2011-10-17 10:22:59 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2011-10-17 10:22:59 +0100
commit30db9be89e11712d26bc46752d75c4cf86760bd7 (patch)
tree2d6e495758fd216a2b2554355e0805465db7d012
parent43ea764b160ca41a599c978f556f8248fe5380be (diff)
downloadtbdiff-30db9be89e11712d26bc46752d75c4cf86760bd7.tar.gz
Should fix directory mtime differences
-rw-r--r--libtbd_apply.c34
-rw-r--r--libtbd_create.c33
2 files changed, 35 insertions, 32 deletions
diff --git a/libtbd_apply.c b/libtbd_apply.c
index a3f2b3e..858af18 100644
--- a/libtbd_apply.c
+++ b/libtbd_apply.c
@@ -136,24 +136,34 @@ static int
tbd_apply_cmd_dir_leave(FILE *stream,
uintptr_t *depth)
{
- uint8_t count;
- if(fread(&count, 1, 1, stream) != 1)
+ int err = TBD_ERROR_SUCCESS;
+ struct utimbuf time;
+
+ if (fread(&(time.modtime), sizeof(time.modtime), 1, stream) != 1) {
return TBD_ERROR(TBD_ERROR_UNABLE_TO_READ_STREAM);
- uintptr_t rcount = count + 1;
- fprintf(stderr, "cmd_dir_leave %"PRIuPTR"\n", rcount);
+ }
+ time.actime = time.modtime;/* not sure what the best atime to use is */
+
+ fprintf(stderr, "cmd_dir_leave\n");
- if((depth != NULL) && (*depth < rcount))
+ /* test for leaving shallowest depth */
+ if ((depth != NULL) && (*depth < 1)) {
return TBD_ERROR(TBD_ERROR_INVALID_PARAMETER);
+ }
- uintptr_t i;
- for(i = 0; i < rcount; i++) {
- if(chdir("..") != 0)
- return TBD_ERROR(TBD_ERROR_UNABLE_TO_CHANGE_DIR);
+ if (utime(".", &time) == -1) {
+ return TBD_ERROR(TBD_ERROR_UNABLE_TO_CHANGE_DIR);
}
- if(depth != NULL)
- *depth -= rcount;
- return 0;
+ if (chdir("..") != 0) {
+ return TBD_ERROR(TBD_ERROR_UNABLE_TO_CHANGE_DIR);
+ }
+
+ if (depth != NULL) {
+ (*depth)--;
+ }
+
+ return err;
}
static int
diff --git a/libtbd_create.c b/libtbd_create.c
index 7aaf744..d6ef029 100644
--- a/libtbd_create.c
+++ b/libtbd_create.c
@@ -372,27 +372,15 @@ tbd_create_cmd_dir_enter(FILE *stream,
static int
tbd_create_cmd_dir_leave(FILE *stream,
- uintptr_t count)
+ tbd_stat_t *dir)
{
- if(count == 0)
- return 0;
int err;
- if((err = tbd_create_fwrite_cmd(stream, TBD_CMD_DIR_LEAVE)) != 0)
+ if ((err = tbd_create_fwrite_cmd(stream, TBD_CMD_DIR_LEAVE)) !=
+ TBD_ERROR_SUCCESS) {
return err;
-
- uint8_t token;
- if(count > 256) {
- token = 255;
- for(; count > 256; count -= 256) {
- if(fwrite(&token, sizeof (uint8_t), 1, stream) != 1)
- return TBD_ERROR(TBD_ERROR_UNABLE_TO_WRITE_STREAM);
- }
}
- token = (count - 1);
- if(fwrite(&token, 1, 1, stream) != 1)
- return TBD_ERROR(TBD_ERROR_UNABLE_TO_WRITE_STREAM);
- return 0;
+ return tbd_create_fwrite_mtime(stream, dir->mtime);
}
static int
@@ -587,7 +575,7 @@ tbd_create_dir(FILE *stream,
return err;
}
- return tbd_create_cmd_dir_leave(stream, 1);
+ return tbd_create_cmd_dir_leave(stream, d);
}
static int
@@ -648,7 +636,10 @@ tbd_create_impl(FILE *stream,
case TBD_STAT_TYPE_DIR:
if(!top) {
fprintf(stderr, "dir delta %s\n", a->name);
- tbd_create_cmd_dir_delta(stream, a, b);
+ if ((err = tbd_create_cmd_dir_delta(stream, a, b)) !=
+ TBD_ERROR_SUCCESS) {
+ return err;
+ }
}
break;
default:
@@ -691,9 +682,11 @@ tbd_create_impl(FILE *stream,
return err;
}
- if(!top && ((err = tbd_create_cmd_dir_leave(stream, 1)) != 0))
+ if(!top && ((err = tbd_create_cmd_dir_leave(stream, b)) !=
+ TBD_ERROR_SUCCESS)) {
return err;
- return 0;
+ }
+ return TBD_ERROR_SUCCESS;
}
int