Example #1
0
/* move record up in folder hierarchy (if possible) */
int record_up(record* r)
{
    if (r->record.type == HFSP_FOLDER)
    {
	// locate folder thread
	if (record_init_cnid(r, r->tree, r->record.u.folder.id))
	    return -1;
    }
    else if(r->record.type == HFSP_FOLDER_THREAD)
    {
	// do nothing were are already where we want to be
    }
    else
	HFSP_ERROR(-1, "record_up: record is neither folder nor folder thread.");

    if(r->record.type != HFSP_FOLDER_THREAD)
	HFSP_ERROR(-1, "record_up: unable to locate parent");
    return record_init_cnid(r, r->tree, r->record.u.thread.parentID);

  fail:
    return -1;
}
Example #2
0
/* ( -- success? ) */
static void
hfsp_files_open( hfsp_info_t *mi )
{
	int fd;
	char *path = my_args_copy();

	if ( ! path )
		RET( 0 );

	fd = open_ih( my_parent() );
	if ( fd == -1 ) {
		free( path );
		RET( 0 );
	}

	mi->vol = malloc( sizeof(volume) );
	if (volume_open(mi->vol, fd)) {
		free( path );
		close_io( fd );
		RET( 0 );
	}

	mi->hfspfile = malloc( sizeof(hfsp_file_t) );
	
	/* Leading \\ means system folder. The finder info block has
	 * the following meaning.
	 *
	 *  [0] Prefered boot directory ID
	 *  [3] MacOS 9 boot directory ID
	 *  [5] MacOS X boot directory ID
	 */
	if( !strncmp(path, "\\\\", 2) ) {
		int *p = (int*)&(mi->vol)->vol.finder_info[0];
		int cnid = p[0];
		/* printk(" p[0] = %x, p[3] = %x, p[5] = %x\n", p[0], p[3], p[5] ); */
		if( p[0] == p[5] && p[3] )
			cnid = p[3];
		if( record_init_cnid(&(mi->hfspfile->rec), &(mi->vol)->catalog, cnid) )
			RET ( 0 );
		path += 2;
	} else {
		record_init_root( &(mi->hfspfile->rec), &(mi->vol)->catalog );
	}

	if( !search_files(&(mi->hfspfile->rec), 0, match_path, path, mi->hfspfile ) )
		RET ( -1 );
	
	RET ( -1 );
}
Example #3
0
/* intialize the record to the first record of the parent.
 */
int record_init_parent(record* r, record* parent)
{
    if (parent->record.type == HFSP_FOLDER)
	return record_init_cnid(r, parent->tree, parent->record.u.folder.id);
    else if(parent->record.type == HFSP_FOLDER_THREAD)
    {
	if (r != parent)
	    *r = *parent; // The folder thread is in fact the first entry, like '.'
	return 0;
    }
    HFSP_ERROR(EINVAL,
	"record_init_parent: parent is neither folder nor folder thread.");

  fail:
    return EINVAL;
}