Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "headers.h"
2
 
3
SmbDirCache *
4
smbmkdircache(SmbTree *t, char *path)
5
{
6
	long n;
7
	SmbDirCache *c;
8
	Dir *buf;
9
	int fd;
10
	char *fullpath = nil;
11
 
12
	smbstringprint(&fullpath, "%s%s", t->serv->path, path);
13
//smblogprintif(1, "smbmkdircache: path %s\n", fullpath);
14
	fd = open(fullpath, OREAD);
15
	free(fullpath);
16
 
17
	if (fd < 0)
18
		return nil;
19
	n = dirreadall(fd, &buf);
20
	close(fd);
21
	if (n < 0) {
22
		free(buf);
23
		return nil;
24
	}
25
	c = smbemalloc(sizeof(SmbDirCache));
26
	c->buf = buf;
27
	c->n = n;
28
	c->i = 0;
29
	return c;
30
}
31
 
32
void
33
smbdircachefree(SmbDirCache **cp)
34
{
35
	SmbDirCache *c;
36
	c = *cp;
37
	if (c) {
38
		free(c->buf);
39
		free(c);
40
		*cp = nil;
41
	}
42
}
43