Line data Source code
1 : #include "../../burp.h"
2 : #include "fdirs.h"
3 : #include "../../alloc.h"
4 : #include "../../prepend.h"
5 :
6 1 : struct fdirs *fdirs_alloc(void)
7 : {
8 1 : return (struct fdirs *)calloc_w(1, sizeof(struct fdirs), __func__);
9 : }
10 :
11 1 : int fdirs_init(struct fdirs *fdirs,
12 : struct sdirs *sdirs, const char *realcurrent)
13 : {
14 2 : if((fdirs->datadir=prepend_s(sdirs->finishing, "data"))
15 1 : && (fdirs->datadirtmp=prepend_s(sdirs->finishing, "data.tmp"))
16 1 : && (fdirs->manifest=prepend_s(sdirs->finishing, "manifest.gz"))
17 1 : && (fdirs->deletionsfile=prepend_s(sdirs->finishing, "deletions"))
18 1 : && (fdirs->currentdup=prepend_s(sdirs->finishing, "currentdup"))
19 1 : && (fdirs->currentduptmp=prepend_s(sdirs->finishing, "currentdup.tmp"))
20 1 : && (fdirs->currentdupdata=prepend_s(fdirs->currentdup, "data"))
21 1 : && (fdirs->timestamp=prepend_s(sdirs->finishing, "timestamp"))
22 1 : && (fdirs->fullrealcurrent=prepend_s(sdirs->client, realcurrent))
23 1 : && (fdirs->logpath=prepend_s(sdirs->finishing, "log"))
24 1 : && (fdirs->hlinked=prepend_s(sdirs->finishing, "hardlinked"))
25 2 : && (fdirs->hlinkedcurrent=prepend_s(sdirs->current, "hardlinked")))
26 : {
27 1 : return 0;
28 : }
29 0 : return -1;
30 : }
31 :
32 1 : static void fdirs_free_content(struct fdirs *fdirs)
33 : {
34 2 : if(!fdirs) return;
35 1 : free_w(&fdirs->datadir);
36 1 : free_w(&fdirs->datadirtmp);
37 1 : free_w(&fdirs->manifest);
38 1 : free_w(&fdirs->deletionsfile);
39 1 : free_w(&fdirs->currentdup);
40 1 : free_w(&fdirs->currentduptmp);
41 1 : free_w(&fdirs->currentdupdata);
42 1 : free_w(&fdirs->timestamp);
43 1 : free_w(&fdirs->fullrealcurrent);
44 1 : free_w(&fdirs->logpath);
45 1 : free_w(&fdirs->hlinked);
46 1 : free_w(&fdirs->hlinkedcurrent);
47 : }
48 :
49 1 : void fdirs_free(struct fdirs **fdirs)
50 : {
51 2 : if(!fdirs || !*fdirs) return;
52 1 : fdirs_free_content(*fdirs);
53 1 : free_v((void **)fdirs);
54 : }
|