summaryrefslogtreecommitdiff
path: root/create.c
diff options
context:
space:
mode:
authorBen Brewer <benbrewer@codethink.co.uk>2011-08-18 12:38:40 +0100
committerBen Brewer <benbrewer@codethink.co.uk>2011-08-18 12:38:40 +0100
commite3a8d2dae4876a7ff136ba4815f973f5085765c8 (patch)
tree8ae251f68f52c6223505589716be9147024618f4 /create.c
parent46d2573668b6f6accfcab5cbc9a610add150abc4 (diff)
downloadtbdiff-e3a8d2dae4876a7ff136ba4815f973f5085765c8.tar.gz
Re-wrote stat functions to be faster, now the trees are generated as needed rather than in their entirety so patching should be much faster and less memory intensive.
Diffstat (limited to 'create.c')
-rw-r--r--create.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/create.c b/create.c
index 8a4e45e..a68408a 100644
--- a/create.c
+++ b/create.c
@@ -19,19 +19,21 @@ int main(int argc, char** argv) {
if(getcwd(cwd_buff, cwd_size) == NULL)
return EXIT_FAILURE;
- dir_stat_t* dstat[2];
+ otap_stat_t* tstat[2];
- dstat[0] = dir_stat(NULL, argv[1]);
- if(dstat[0] == NULL) {
- fprintf(stderr, "Error: Unable to stat directory '%s'.\n", argv[1]);
+ tstat[0] = otap_stat(argv[1]);
+ if(tstat[0] == NULL) {
+ fprintf(stderr, "Error: Unable to stat '%s'.\n", argv[1]);
return EXIT_FAILURE;
}
+ chdir(cwd_buff);
- dstat[1] = dir_stat(NULL, argv[2]);
- if(dstat[1] == NULL) {
- fprintf(stderr, "Error: Unable to stat directory '%s'.\n", argv[2]);
+ tstat[1] = otap_stat(argv[2]);
+ if(tstat[1] == NULL) {
+ fprintf(stderr, "Error: Unable to stat '%s'.\n", argv[2]);
return EXIT_FAILURE;
}
+ chdir(cwd_buff);
FILE* fp = fopen("patch.otap", "wb");
if(fp == NULL) {
@@ -39,7 +41,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- if(!otap_create(fp, dstat[0], dstat[1])) {
+ if(!otap_create(fp, tstat[0], tstat[1])) {
fclose(fp);
remove("patch.otap");
fprintf(stderr, "Error: Failed to create otap.\n");
@@ -47,6 +49,8 @@ int main(int argc, char** argv) {
}
fclose(fp);
+ otap_stat_free(tstat[0]);
+ otap_stat_free(tstat[1]);
return EXIT_SUCCESS;
}