diff options
| author | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-01-03 10:04:01 -0500 |
|---|---|---|
| committer | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2014-01-03 10:04:01 -0500 |
| commit | 50ff0e53d94c60860e768100f549e4dfe9110096 (patch) | |
| tree | 65175313745a4aad498d781092dd89f8fbd47276 /rfile.c | |
| parent | 2719471cb97c721e929c98c6bad40a381269295e (diff) | |
| download | prism-50ff0e53d94c60860e768100f549e4dfe9110096.tar.gz prism-50ff0e53d94c60860e768100f549e4dfe9110096.zip | |
Files can now be committed to version control. Each version is stored in gzip'd form. Fix to MD5 calculation.
Diffstat (limited to 'rfile.c')
| -rw-r--r-- | rfile.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -5,6 +5,7 @@ #include "prism.h"
#include "md5.h"
#include "rfile.h"
+#include "compress.h"
static const char hex_str[]= "0123456789abcdef";
@@ -23,8 +24,8 @@ int i; return PRET_READERROR;
MD5_Init(&hb);
- while(fgets(buf, 15, fp)) {
- MD5_Update(&hb, buf, strlen(buf));
+ while((i = fread(buf, sizeof(char), 15, fp)) > 0) {
+ MD5_Update(&hb, buf, i);
}
fclose(fp);
@@ -37,3 +38,19 @@ int i; return PRET_OK;
}
+
+int compress_file(const char *filename, int id, int revision)
+{
+char *newfile;
+
+ /* Arbitrary size... */
+ newfile = (char *)malloc(128*sizeof(char));
+ if(newfile == NULL)
+ return PRET_ERROR;
+ snprintf(newfile, 128, "%s%s%x.%x", PDB_DIR, DIR_SEP, id, revision);
+
+ if(file_compress(filename, newfile) >= 0)
+ return PRET_OK;
+
+ return PRET_GZFAILED;
+}
|
