示例#1
0
acl_uint64 scan_dir::remove_all(int* nfiles /* = NULL */,
	int* ndirs /* = NULL */) const
{
	if (scan_ == NULL)
		return 0;
	return (acl_uint64) acl_scan_dir_rm2(scan_, nfiles, ndirs);
}
示例#2
0
acl_int64 acl_scan_dir_rm(const char *pathname, int recursive, int *ndir, int *nfile)
{
	const char *myname = "acl_scan_dir_rmall";
	ACL_SCAN_DIR *scan;
	struct acl_stat sbuf;
	acl_int64 nsize;
	char tbuf[256];

	if (ndir)
		*ndir = 0;
	if (nfile)
		*nfile = 0;

	if (acl_stat(pathname, &sbuf) < 0) {
		acl_msg_error("%s(%d), %s: stat pathname(%s) error(%s)",
			__FILE__, __LINE__, myname, pathname,
			acl_last_strerror(tbuf, sizeof(tbuf)));
		return (-1);
	}
	if (S_ISDIR(sbuf.st_mode) == 0) {
		if (nfile)
			*nfile = 1;
		SANE_UNLINK(pathname);

		return (1);
	}

	scan = acl_scan_dir_open(pathname, recursive);
	if (scan == NULL) {
		acl_msg_error("%s(%d), %s: open path(%s) error(%s)",
			__FILE__, __LINE__, myname,
			pathname, acl_last_strerror(tbuf, sizeof(tbuf)));
		return (-1);
	}

	acl_scan_dir_rm2(scan);

	if (ndir)
		*ndir = scan->ndirs;
	if (nfile)
		*nfile = scan->nfiles;
	nsize = scan->nsize;
	acl_scan_dir_close(scan);
	return (nsize);
}