Incremental progress
This commit is contained in:
parent
1d36b38fb4
commit
a53032eea9
1 changed files with 21 additions and 4 deletions
25
src/haggis.c
25
src/haggis.c
|
@ -331,12 +331,10 @@ int haggis_load_filename(FILE *stream, haggis_filename *n) {
|
|||
char *name;
|
||||
|
||||
len.val = 0;
|
||||
if (fread(len.bytes, 1, 2, stream) != 2)
|
||||
return 2;
|
||||
if (fread(len.bytes, 1, 2, stream) != 2) return 2;
|
||||
n->len = len;
|
||||
name = malloc((size_t)len.val);
|
||||
if (name == NULL)
|
||||
return -1;
|
||||
if (name == NULL) return -1;
|
||||
if (fread(name, 1, (size_t)len.val, stream) != (size_t)len.val) {
|
||||
free(name);
|
||||
return 2;
|
||||
|
@ -345,6 +343,13 @@ int haggis_load_filename(FILE *stream, haggis_filename *n) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int haggis_store_filename(FILE *stream, haggis_filename *n) {
|
||||
if (fwrite(n->len.bytes, 1, 2, stream) != 2) return 2;
|
||||
if (fwrite(n->name, 1, (size_t)n->len.val, stream) != (size_t)n->len.val)
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int haggis_load_filetype(FILE *stream, haggis_typeflag tag, haggis_filetype *file) {
|
||||
switch (tag) {
|
||||
case normal:
|
||||
|
@ -381,6 +386,13 @@ haggis_typeflag haggis_filetype_from_mode(u16 mode) {
|
|||
return filetype;
|
||||
}
|
||||
|
||||
u16 haggis_combine_mode(u16 raw, haggis_ft ft) {
|
||||
u16 mode;
|
||||
mode.val = 0;
|
||||
//todo
|
||||
return mode;
|
||||
}
|
||||
|
||||
haggis_node* haggis_create_node(char *file) {
|
||||
haggis_node *node = malloc(sizeof(haggis_node));
|
||||
if (node == NULL)
|
||||
|
@ -425,6 +437,11 @@ int haggis_load_node(FILE *stream, haggis_node *node) {
|
|||
}
|
||||
|
||||
int haggis_store_node(FILE *stream, haggis_node *node) {
|
||||
if (haggis_store_filename(stream, node->name) != (size_t)(node->name->len.val) + 2)
|
||||
return 2;
|
||||
if (store_u32(stream, node->uid) != 4) return 2;
|
||||
if (store_u32(stream, node->gid) != 4) return 2;
|
||||
if (store_u64(stream, node->mtime) != 8) return 2;
|
||||
// todo
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue