blob: 0a88f8e585dd19a92e9e00164d0ab6d35270c0f0 (
plain)
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
|
#include "internal.h"
static void
delete(fs·History *h)
{
SET_FREE(h, base·Memory, nil);
}
int
fs·init(fs·Walker *fs, char *path)
{
fs->base = fs->end = fs->path;
if(!path || !path[0]){
if(sys·cwd(fs->path, arrlen(fs->path)))
return 1;
fs->end += str·len(path);
}else
fs->end = str·ncopy(fs->base, arrlen(fs->path), path);
if(fs->path[0] != '/')
fs->fd = sys·FdCwd;
if(!fs->hist && !(fs->flags & fs·nolinks))
fs->hist = calloc(1, sizeof(*fs->hist));
return 0;
}
void
fs·fini(fs·Walker *fs)
{
if(fs->hist){
delete(fs->hist);
free(fs->hist);
}
}
|