blob: d988d132ea84d5578ee847b7d458082eb7d76ed8 (
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
38
|
#include "internal.h"
static void
delete(fs·History *h)
{
SET_FREE(h, sys·Memory, nil);
}
int
fs·init(fs·Walker *fs, char *path)
{
fs->base = fs->end = fs->path;
if(!path || !path[0]){
path = getcwd(fs->path, arrlen(fs->path));
if (!path)
return 1;
fs->end += strlen(path);
}else
fs->end = str·ncopy(fs->base, arrlen(fs->path), path);
if(fs->path[0] != '/')
fs->fd = AT_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);
}
}
|