Merge branch 'odin' of git.hitchhiker-linux.org:jeang3nie/seahag into odin
This commit is contained in:
commit
46d0892b77
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;
|
char *name;
|
||||||
|
|
||||||
len.val = 0;
|
len.val = 0;
|
||||||
if (fread(len.bytes, 1, 2, stream) != 2)
|
if (fread(len.bytes, 1, 2, stream) != 2) return 2;
|
||||||
return 2;
|
|
||||||
n->len = len;
|
n->len = len;
|
||||||
name = malloc((size_t)len.val);
|
name = malloc((size_t)len.val);
|
||||||
if (name == NULL)
|
if (name == NULL) return -1;
|
||||||
return -1;
|
|
||||||
if (fread(name, 1, (size_t)len.val, stream) != (size_t)len.val) {
|
if (fread(name, 1, (size_t)len.val, stream) != (size_t)len.val) {
|
||||||
free(name);
|
free(name);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -345,6 +343,13 @@ int haggis_load_filename(FILE *stream, haggis_filename *n) {
|
||||||
return 0;
|
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) {
|
int haggis_load_filetype(FILE *stream, haggis_typeflag tag, haggis_filetype *file) {
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case normal:
|
case normal:
|
||||||
|
@ -381,6 +386,13 @@ haggis_typeflag haggis_filetype_from_mode(u16 mode) {
|
||||||
return filetype;
|
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* haggis_create_node(char *file) {
|
||||||
haggis_node *node = malloc(sizeof(haggis_node));
|
haggis_node *node = malloc(sizeof(haggis_node));
|
||||||
if (node == NULL)
|
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) {
|
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
|
// todo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue