-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.c
More file actions
42 lines (32 loc) · 866 Bytes
/
example.c
File metadata and controls
42 lines (32 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "compdoc.h"
#include <stdio.h>
int main(int argc, char **argv)
{
if(argc != 2)
{
printf("wrong arguments\n");
return -1;
}
comp_doc_file_t *file;
unsigned char *buffer;
uint32_t dirid = 0;
if((dirid = comp_doc_open(argv[1], COMP_DOC_PERM_READ_WRITE, &file)) != 0)
{
fprintf(stderr, "failed to open file %s (%d)\n", argv[1], (int32_t)dirid);
return -1;
}
comp_doc_directory_t *directory;
for(dirid = 0; dirid < file->ndirs; dirid++)
{
directory = comp_doc_get_directory(file, dirid);
if(IS_DIR_STREAM(directory))
break;
}
comp_doc_read_stream(file, directory, &buffer);
FILE *fp;
fp = fopen("/tmp/stream.bin", "w");
fwrite(buffer, directory->size, 1, fp);
fclose(fp);
comp_doc_close(file);
return 0;
}