|
This thread is locked; no one can reply to it. |
1
2
|
editting a file |
William Labbett
Member #4,486
March 2004
|
Thanks for the help guys. Just wondering what I should do instead of using ftruncate now. I guess I'll have to rewrite the whole file when I want to change it's size ?
|
OnlineCop
Member #7,919
October 2006
|
1void save(struct F_REP* f_rep, PACKFILE* pf)
2{
3 assert(F_REP && "f_rep was passed in as a NULL pointer!");
4 assert(pf && "pf was passed in as a NULL pointer!");
5
6 /**< first, write the # of actually-used bytes in this string */
7 pack_iputl(strlen(f_rep->png_filename), pf);
8
9 pack_iputl(f_rep->type, pf);
10 pack_iputl(f_rep->squares_wide_on_map, pf);
11 ...
12 pack_iputl(f_rep->has_mask, pf);
13}
14
15
16void read(struct F_REP* f_rep, PACKFILE* pf)
17{
18 size_t len_filename = 0;
19
20 assert(F_REP && "f_rep was passed in as a NULL pointer!");
21 assert(pf && "pf was passed in as a NULL pointer!");
22
23 /**< first, read in the number of bytes in the string */
24 len_filename = pack_igetl(pf);
25 pack_fread(&f_rep->png_filename, len_filename, pf);
26 if (pack_feof(pf))
27 exit_with_error("EOF reached after reading in `png_filename'!\n");
28
29 f_rep->type = pack_igetl(pf);
30 f_rep->squares_wide_on_map = pack_igetl(pf);
31 ...
32 f_rep->has_mask = = pack_igetl(pf);
33}
|
|
1
2
|