コード例 #1
0
ファイル: storage.cpp プロジェクト: bradc6/libdar
    storage::storage(generic_file & f, const infinint & size)
    {
        U_32 lu, tmp;
        make_alloc(size, first, last);
        struct cellule *ptr = first;

        try
        {
            while(ptr != NULL)
            {
                lu = 0;

                do
                {
                    tmp = f.read(((char *)(ptr->data))+lu, ptr->size - lu);
                    lu += tmp;
                }
                while(lu < ptr->size && tmp != 0);

                if(lu < ptr->size)
                    throw Erange("storage::storage", gettext("Not enough data to initialize storage field"));
                ptr = ptr->next;
            }
        }
        catch(...)
        {
            detruit(first);
	    first = NULL;
	    last = NULL;
            throw;
        }
    }
コード例 #2
0
ファイル: slice_layout.cpp プロジェクト: simon-el/dar-code
    void slice_layout::read(generic_file & f)
    {
	char tmp;

	first_size.read(f);
	other_size.read(f);
	first_slice_header.read(f);
	other_slice_header.read(f);
	if(f.read(&tmp , 1) == 1)
	{
	    switch(tmp)
	    {
	    case OLDER_THAN_V8:
		older_sar_than_v8 = true;
		break;
	    case V8:
		older_sar_than_v8 = false;
		break;
	    default:
		throw SRC_BUG;
	    }
	}
	else
	    throw Erange("slice_layout::read", gettext("Missing data while reading slice_layout object"));
    }
コード例 #3
0
    fsa_bool::fsa_bool(generic_file & f, fsa_family fam, fsa_nature nat):
	filesystem_specific_attribute(f, fam, nat)
    {
	char ch;
	S_I lu = f.read(&ch, 1);

	if(lu == 1)
	{
	    switch(ch)
	    {
	    case 'T':
		val = true;
		break;
	    case 'F':
		val = false;
		break;
	    default:
		throw Edata(gettext("Unexepected value for boolean FSA, data corruption may have occurred"));
	    }
	}
	else
	    throw Erange("fsa_bool::fsa_bool", string(gettext("Error while reading FSA: ")) + strerror(errno));
    }
コード例 #4
0
    void filesystem_specific_attribute_list::read(generic_file & f)
    {
	infinint size = infinint(f);
	U_I sub_size;

	do
	{
	    sub_size = 0;
	    size.unstack(sub_size);
	    if(size > 0 && sub_size == 0)
		throw SRC_BUG;

	    while(sub_size > 0)
	    {
		char buffer[FAM_SIG_WIDTH + NAT_SIG_WIDTH + 1];
		fsa_family fam;
		fsa_nature nat;
		filesystem_specific_attribute *ptr = NULL;

		f.read(buffer, FAM_SIG_WIDTH);
		buffer[FAM_SIG_WIDTH] = '\0';
		fam = signature_to_family(buffer);

		f.read(buffer, NAT_SIG_WIDTH);
		buffer[NAT_SIG_WIDTH] = '\0';
		nat = signature_to_nature(buffer);

		switch(nat)
		{
		case fsan_unset:
		    throw SRC_BUG;
		case fsan_creation_date:
		    ptr = new (nothrow) fsa_infinint(f, fam, nat);
		    break;
		case fsan_append_only:
		case fsan_compressed:
		case fsan_no_dump:
		case fsan_immutable:
		case fsan_data_journalling:
		case fsan_secure_deletion:
		case fsan_no_tail_merging:
		case fsan_undeletable:
		case fsan_noatime_update:
		case fsan_synchronous_directory:
		case fsan_synchronous_update:
		case fsan_top_of_dir_hierarchy:
		    ptr = new (nothrow) fsa_bool(f, fam, nat);
		    break;
		default:
		    throw SRC_BUG;
		}

		if(ptr == NULL)
		    throw Ememory("filesystem_specific_attribute_list::read");
		fsa.push_back(ptr);
		ptr = NULL;

		--sub_size;
	    }
	}
	while(size > 0);

	update_familes();
	sort_fsa();
    }
コード例 #5
0
ファイル: compressor.cpp プロジェクト: bradc6/libdar
    void compressor::lzo_block_header::set_from(generic_file & f)
    {
	f.read(&type, 1);
	size.read(f);
    }