summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brewer <benbrewer@codethink.co.uk>2011-08-18 13:26:11 +0100
committerBen Brewer <benbrewer@codethink.co.uk>2011-08-18 13:26:11 +0100
commit7d3ed8c96eaf05119c02701c365d6504ed90abca (patch)
tree7c55165ab31e5066a8d1062b5a70030b8d822b21
parentc7181d7b058710bab61b5dc08a5c45cbe35b9804 (diff)
downloadtbdiff-7d3ed8c96eaf05119c02701c365d6504ed90abca.tar.gz
Metadata (modified time) is now set when applying patches.
-rw-r--r--.gitignore2
-rw-r--r--build.log3
-rw-r--r--otap_apply.c14
3 files changed, 14 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3bc0e7b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+otap_create
+otap_deploy
diff --git a/build.log b/build.log
deleted file mode 100644
index e4432b7..0000000
--- a/build.log
+++ /dev/null
@@ -1,3 +0,0 @@
-gcc -Wall -Wextra -O2 create.c otap*.c stat.c -o otap_create
-stat.c: In function ‘otap_stat_print’:
-stat.c:78:35: warning: unused parameter ‘file’
diff --git a/otap_apply.c b/otap_apply.c
index 7ba802b..cbcf296 100644
--- a/otap_apply.c
+++ b/otap_apply.c
@@ -6,10 +6,13 @@
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
+#include <time.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
+#include <utime.h>
+
@@ -103,7 +106,6 @@ static bool _otap_apply_cmd_file_create(FILE* stream) {
uint32_t mtime;
if(fread(&mtime, 4, 1, stream) != 1)
return false;
- // TODO - Apply metadata (mtime, etc.)
uint32_t fsize;
if(fread(&fsize, 4, 1, stream) != 1)
@@ -133,6 +135,10 @@ static bool _otap_apply_cmd_file_create(FILE* stream) {
}
fclose(fp);
+ // Apply metadata.
+ struct utimbuf timebuff = { time(NULL), mtime };
+ utime(fname, &timebuff); // Don't care if it succeeds right now.
+
return true;
}
@@ -151,7 +157,6 @@ static bool _otap_apply_cmd_file_delta(FILE* stream) {
uint32_t mtime;
if(fread(&mtime, 4, 1, stream) != 1)
return false;
- // TODO - Apply metadata (mtime, etc.)
FILE* op = fopen(fname, "rb");
if(op == NULL)
@@ -210,6 +215,11 @@ static bool _otap_apply_cmd_file_delta(FILE* stream) {
fclose(np);
fclose(op);
+
+ // Apply metadata.
+ struct utimbuf timebuff = { time(NULL), mtime };
+ utime(fname, &timebuff); // Don't care if it succeeds right now.
+
return true;
}