Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/aquarela/smbdircache.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "headers.h"

SmbDirCache *
smbmkdircache(SmbTree *t, char *path)
{
	long n;
	SmbDirCache *c;
	Dir *buf;
	int fd;
	char *fullpath = nil;

	smbstringprint(&fullpath, "%s%s", t->serv->path, path);
//smblogprintif(1, "smbmkdircache: path %s\n", fullpath);
	fd = open(fullpath, OREAD);
	free(fullpath);

	if (fd < 0)
		return nil;
	n = dirreadall(fd, &buf);
	close(fd);
	if (n < 0) {
		free(buf);
		return nil;
	}
	c = smbemalloc(sizeof(SmbDirCache));
	c->buf = buf;
	c->n = n;
	c->i = 0;
	return c;
}

void
smbdircachefree(SmbDirCache **cp)
{
	SmbDirCache *c;
	c = *cp;
	if (c) {
		free(c->buf);
		free(c);
		*cp = nil;
	}
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].