Beispiel #1
0
int
cole_locate_filename(COLEFS * colefilesystem, char *filename,
                     void *info,
                     COLE_LOCATE_ACTION_FUNC * action, COLERRNO * colerrno)
{
    struct __cole_locate_filenameinfo _info;
    COLERRNO _colerrno;

    if (filename[0] != '/') {
        if (colerrno != NULL)
            *colerrno = COLE_EBROKENFILENAME;
        return 1;
    }

    _info.action = action;
    _info.info = info;
    _info.filename = filename;
    _info.current = filename + 1;

    if (cole_recurse_tree(colefilesystem, &_info, NULL,
                          & __cole_locate_filename_indirentry, NULL, NULL,
                          & __cole_locate_filename_visitdir, &_colerrno)) {
        if (_colerrno == COLE_ELAST + 1) {
            /* file was found */
            return 0;
        }
        if (colerrno != NULL)
            *colerrno = _colerrno;
        return 1;
    }

    if (colerrno != NULL)
        *colerrno = COLE_EFILENOTFOUND;
    return 1;
}
Beispiel #2
0
void cole_print_tree(COLEFS * colefilesystem, COLERRNO * colerrno)
{
    int32_t level = 1;

    (void) cole_recurse_tree(colefilesystem, 
                          &level,
                          & __cole_print_tree_inroot,
                          & __cole_print_tree_indirentry,
                          & __cole_print_tree_indir,
                          & __cole_print_tree_outdir, 
                          NULL, 
                          colerrno);
}
int
main (int argc, char **argv)
{
	COLEFS * cfs;
	COLERRNO colerrno;

	/* To test cole_locate_filename() */
#define FILENAME "/ObjectPool/_994231763/\001Ole10Native"
	struct str_info info = { FILENAME, 108004 };


	cfs = cole_mount (COLE_TOPSRCDIR"/examples/text.doc", &colerrno);
	if (cfs == NULL) {
		cole_perror (PRGNAME, colerrno);
		exit (1);
	}


	if (cole_print_tree (cfs, &colerrno)) {
		cole_perror (PRGNAME, colerrno);
		cole_umount (cfs, NULL);
		exit (1);
	}


	if (cole_locate_filename (cfs, FILENAME, &info, check_size,
				  &colerrno)) {
		cole_perror (PRGNAME, colerrno);
		cole_umount (cfs, NULL);
		exit (1);
	}


	if (cole_recurse_tree (cfs, NULL, NULL, NULL, NULL, NULL, NULL,
			       &colerrno)) {
		cole_perror (PRGNAME, colerrno);
		cole_umount (cfs, NULL);
		exit (1);
	}


	if (cole_umount (cfs, &colerrno)) {
		cole_perror ("travel", colerrno);
		exit (1);
	}

	exit (0);
}
Beispiel #4
0
int
cole_print_tree (COLEFS *colefilesystem, COLERRNO *colerrno)
{
	long level;

	level = 1;
	if (cole_recurse_tree (colefilesystem, &level,
			       __cole_print_tree_inroot,
			       __cole_print_tree_indirentry,
			       __cole_print_tree_indir,
			       __cole_print_tree_outdir, NULL, colerrno)) {
		return 1;
	}

	return 0;
}