⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udf.c

📁 一款功能很强的光盘镜象制作工具
💻 C
📖 第 1 页 / 共 3 页
字号:
		}	}	return link_count;}static void#ifdef PROTOTYPESwrite_one_udf_directory(struct directory *dpnt, FILE *outfile)#elsewrite_one_udf_directory(dpnt,outfile)	struct directory	*dpnt;	FILE			*outfile;#endif{	unsigned size_in_bytes, padded_size_in_bytes;	struct directory_entry *de;	unsigned ident_size;	unsigned base_sector;	struct directory *parent;	Uchar buf[SECTOR_SIZE];	memset(buf, 0, SECTOR_SIZE);	set_file_entry(		buf,		last_extent_written - lba_udf_partition_start,		last_extent_written+1 - lba_udf_partition_start,		directory_size(dpnt),		dpnt->self->isorec.date,		1,	/* is_directory */		directory_link_count(dpnt),		(dpnt == root) ? 0 : dpnt->self->udf_file_entry_sector);	xfwrite(buf, SECTOR_SIZE, 1, outfile);	last_extent_written++;	base_sector = last_extent_written - lba_udf_partition_start;	/* parent directory */	parent = dpnt->parent;	if (parent == reloc_dir) {		parent = dpnt->self->parent_rec->filedir;	}	ident_size = set_file_ident_desc(		buf,		base_sector,		0,		1,		parent->self->udf_file_entry_sector - lba_udf_partition_start,		(parent == root) ? 0 : parent->self->udf_file_entry_sector);	xfwrite(buf, ident_size, 1, outfile);	size_in_bytes = ident_size;	/* directory contents */	for (de = dpnt->jcontents; de; de = de->jnext) {		char *name;		struct directory_entry *de1;		if (de->de_flags & INHIBIT_JOLIET_ENTRY)			continue;		name = USE_MAC_NAME(de) ? de->hfs_ent->name : de->name;		/* skip . and .. */		if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0)))			continue;		/* look in RR_MOVED for relocated directories */		de1 = de;		if (de->de_flags & RELOCATED_DIRECTORY) {			for (de1 = reloc_dir->contents; de1; de1 = de1->next) {				if (de1->parent_rec == de) {					break;				}			}			if (!de1) {#ifdef	USE_LIBSCHILY				comerrno(EX_BAD,				"Unable to locate relocated directory\n");#else				fprintf(stderr,				"Unable to locate relocated directory\n");				exit(1);#endif			}		}		ident_size = set_file_ident_desc(			buf,			base_sector + (size_in_bytes / SECTOR_SIZE),			name,			!!(de1->isorec.flags[0] & ISO_DIRECTORY),			de1->udf_file_entry_sector - lba_udf_partition_start,			de1->udf_file_entry_sector);		xfwrite(buf, ident_size, 1, outfile);		size_in_bytes += ident_size;	}	padded_size_in_bytes = PAD(size_in_bytes, SECTOR_SIZE);	if (size_in_bytes < padded_size_in_bytes) {		memset(buf, 0, padded_size_in_bytes - size_in_bytes);		xfwrite(buf, padded_size_in_bytes - size_in_bytes, 1, outfile);	}	last_extent_written += padded_size_in_bytes / SECTOR_SIZE;}static void#ifdef PROTOTYPESwrite_udf_directories(struct directory *dpnt, FILE *outfile)#elsewrite_udf_directories(dpnt,outfile)	struct directory	*dpnt;	FILE			*outfile;#endif{	if (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY)) {		write_one_udf_directory(dpnt, outfile);	}	if (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir) {		for (dpnt = dpnt->subdir; dpnt; dpnt = dpnt->next) {			write_udf_directories(dpnt, outfile);		}	}}static void#ifdef PROTOTYPESwrite_udf_file_entries(struct directory *dpnt, FILE *outfile)#elsewrite_udf_file_entries(dpnt,outfile)	struct directory	*dpnt;	FILE			*outfile;#endif{	Uchar buf[SECTOR_SIZE];	memset(buf, 0, SECTOR_SIZE);	if (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY)) {		struct directory_entry *de;		for (de = dpnt->jcontents; de; de = de->jnext) {			if (!(de->isorec.flags[0] & ISO_DIRECTORY)) {				memset(buf, 0, 512);				set_file_entry(					buf,					(last_extent_written++) - lba_udf_partition_start,					read_733(de->isorec.extent) - lba_udf_partition_start,					read_733(de->isorec.size),					de->isorec.date,					0,	/* is_directory */					1,	/* link_count */					de->udf_file_entry_sector);				xfwrite(buf, SECTOR_SIZE, 1, outfile);			}		}	}	if (!(dpnt->dir_flags & INHIBIT_JOLIET_ENTRY) || dpnt == reloc_dir) {		for (dpnt = dpnt->subdir; dpnt; dpnt = dpnt->next) {			write_udf_file_entries(dpnt, outfile);		}	}}/****************************/static int#ifdef PROTOTYPESudf_vol_recognition_area_write(FILE *out)#elseudf_vol_recognition_area_write(out)	FILE	*out;#endif{	static const char *identifiers[3] = { "BEA01", "NSR02", "TEA01" };	int i;	char buf[SECTOR_SIZE];	udf_volume_recognition_desc *vsd = (udf_volume_recognition_desc *)buf;	memset(buf, 0, sizeof(buf));	/*set8(&vsd->structure_type, 0);*/	set8(&vsd->structure_version, 1);	for (i = 0; i < 3; ++i) {		memcpy(vsd->standard_identifier, identifiers[i], 5);		xfwrite(buf, 1, SECTOR_SIZE, out);	}	last_extent_written += 3;	return 0;}static int#ifdef PROTOTYPESudf_main_seq_write(FILE *out)#elseudf_main_seq_write(out)	FILE	*out;#endif{	Uchar buf[SECTOR_SIZE];	int i;	/*	 * volume_set_id needs to be set to a (64-bit) "unique" number.	 * This will have to do for now.	 */	time((time_t *)&volume_set_id[0]);	volume_set_id[1] = (unsigned)clock();	/* XXX Maybe non-portable */	memset(buf, 0, sizeof(buf));	set_primary_vol_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	set_impl_use_vol_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	set_partition_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	set_logical_vol_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	set_unallocated_space_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	set_terminating_desc(buf, last_extent_written++);	xfwrite(buf, SECTOR_SIZE, 1, out);	memset(buf, 0, sizeof(buf));	for (i = 6; i < UDF_MAIN_SEQ_LENGTH; ++i) {		xfwrite(buf, SECTOR_SIZE, 1, out);		last_extent_written++;	}	return 0;}static int#ifdef PROTOTYPESudf_integ_seq_write(FILE *out)#elseudf_integ_seq_write(out)	FILE	*out;#endif{	Uchar buf[SECTOR_SIZE*UDF_INTEG_SEQ_LENGTH];	memset(buf, 0, sizeof(buf));	set_logical_vol_integrity_desc(buf+0*SECTOR_SIZE, last_extent_written++);	set_terminating_desc(buf+1*SECTOR_SIZE, last_extent_written++);	xfwrite(buf, UDF_INTEG_SEQ_LENGTH, SECTOR_SIZE, out);	return 0;}static int#ifdef PROTOTYPESudf_anchor_vol_desc_write(FILE *out)#elseudf_anchor_vol_desc_write(out)	FILE	*out;#endif{	Uchar buf[SECTOR_SIZE];	memset(buf, 0, sizeof(buf));	set_anchor_volume_desc_pointer(buf, last_extent_written++);	xfwrite(buf, 1, SECTOR_SIZE, out);	return 0;}static int#ifdef PROTOTYPESudf_file_set_desc_write(FILE *out)#elseudf_file_set_desc_write(out)	FILE	*out;#endif{	Uchar buf[SECTOR_SIZE*2];	memset(buf, 0, sizeof(buf));	set_file_set_desc(buf+0*SECTOR_SIZE, (last_extent_written++) - lba_udf_partition_start);	set_terminating_desc(buf+1*SECTOR_SIZE, (last_extent_written++) - lba_udf_partition_start);	xfwrite(buf, 2, SECTOR_SIZE, out);	return 0;}static int#ifdef PROTOTYPESudf_dirtree_write(FILE *out)#elseudf_dirtree_write(out)	FILE	*out;#endif{	write_udf_directories(root, out);	return 0;}static int#ifdef PROTOTYPESudf_file_entries_write(FILE *out)#elseudf_file_entries_write(out)	FILE	*out;#endif{	write_udf_file_entries(root, out);	return 0;}static int#ifdef PROTOTYPESpad_to(unsigned last_extent_to_write, FILE *out)#elsepad_to(last_extent_to_write,out)	unsigned	last_extent_to_write;	FILE		*out;#endif{	char buf[SECTOR_SIZE];	memset(buf, 0, sizeof(buf));	while (last_extent_written < last_extent_to_write) {		xfwrite(buf, 1, SECTOR_SIZE, out);		++last_extent_written;	}	return 0;}static int#ifdef PROTOTYPESudf_pad_to_sector_32_write(FILE *out)#elseudf_pad_to_sector_32_write(out)	FILE	*out;#endif{	return pad_to(session_start+32, out);}static int#ifdef PROTOTYPESudf_pad_to_sector_256_write(FILE *out)#elseudf_pad_to_sector_256_write(out)	FILE	*out;#endif{	return pad_to(session_start+256, out);}static int#ifdef PROTOTYPESudf_padend_avdp_write(FILE *out)#elseudf_padend_avdp_write(out)	FILE	*out;#endif{	Uchar buf[SECTOR_SIZE];	unsigned last_extent_to_write = (last_extent_written+31) & ~15;	memset(buf, 0, sizeof(buf));	while (last_extent_written < last_extent_to_write) {		set_anchor_volume_desc_pointer(buf, last_extent_written++);		xfwrite(buf, 1, SECTOR_SIZE, out);	}	return 0;}struct output_fragment udf_vol_recognition_area_frag = { NULL, udf_vol_recognition_area_size, NULL, udf_vol_recognition_area_write, "UDF volume recognition area" };struct output_fragment udf_main_seq_frag = { NULL, udf_main_seq_size, NULL, udf_main_seq_write, "UDF main seq" };struct output_fragment udf_main_seq_copy_frag = { NULL, udf_main_seq_copy_size, NULL, udf_main_seq_write, "UDF second seq" };struct output_fragment udf_integ_seq_frag = { NULL, udf_integ_seq_size, NULL, udf_integ_seq_write, "UDF integ seq" };struct output_fragment udf_anchor_vol_desc_frag = { NULL, oneblock_size, NULL, udf_anchor_vol_desc_write, "UDF Anchor volume" };struct output_fragment udf_file_set_desc_frag = { NULL, udf_file_set_desc_size, NULL, udf_file_set_desc_write, "UDF file set" };struct output_fragment udf_dirtree_frag = { NULL, udf_dirtree_size, NULL, udf_dirtree_write, "UDF directory tree" };struct output_fragment udf_file_entries_frag = { NULL, udf_file_entries_size, NULL, udf_file_entries_write, "UDF file entries" };struct output_fragment udf_end_anchor_vol_desc_frag = { NULL, udf_end_anchor_vol_desc_size, NULL, udf_anchor_vol_desc_write, "UDF Anchor end volume" };struct output_fragment udf_pad_to_sector_32_frag = { NULL, udf_pad_to_sector_32_size, NULL, udf_pad_to_sector_32_write, "UDF pad to sector 32 write" };struct output_fragment udf_pad_to_sector_256_frag = { NULL, udf_pad_to_sector_256_size, NULL, udf_pad_to_sector_256_write, "UDF pad to sector 256" };struct output_fragment udf_padend_avdp_frag = { NULL, udf_padend_avdp_size, NULL, udf_padend_avdp_write, "UDF Pad end" };/* * This function assigns weights as follows: * * /VIDEO_TS/VIDEO_TS.IFO   11199 * /VIDEO_TS/VIDEO_TS.VOB   11198 * /VIDEO_TS/VIDEO_TS.BUP   11188 * /VIDEO_TS/VTS_01_0.IFO   11187 * /VIDEO_TS/VTS_01_0.VOB   11186 *            :               : * /VIDEO_TS/VTS_01_9.VOB   11177 * /VIDEO_TS/VTS_01_0.BUP   11176 *            :               : * /VIDEO_TS/VTS_99_0.BUP   10000 * * This ensures that DVD-Video files are laid out properly on the disc. * The same thing is done for AUDIO_TS files, except in the 20000 range * instead of the 10000 range. * * Question: what about JACKET_P files? * * Answer: At least as far as I know :) * JACKET_P files are still images (single frame mpeg video .i.e mp2 * format). The DVD Jacket pictures will be displayed on the TV screen * when the player is in a stop/resume mode. * The location is not dependent on IFO information and the only must * as far as I know is that they are in upper case (both dir and files). * This sparce information makes me conclude that they don't need any * weight. This obviously needs to be tested. */int#ifdef PROTOTYPESassign_dvd_weights(char *name, struct directory *this_dir, int val)#elseassign_dvd_weights(name,this_dir,val)	char			*name;	struct directory	*this_dir;	int			val;#endif{	int ts_number;	int segment;	int audio;	if (name[0] != 'A' && name[0] != 'V')		return val;	if (memcmp(name, "VIDEO_TS", 8) == 0) {		ts_number = 0;		audio = 0;	} else if (memcmp(name, "VTS_", 4) == 0) {		ts_number = 1;		audio = 0;	} else if (memcmp(name, "AUDIO_TS", 8) == 0) {		ts_number = 0;		audio = 1;	} else if (memcmp(name, "ATS_", 4) == 0) {		ts_number = 1;		audio = 1;	} else {		return val;	}	if (this_dir->parent != root || strcmp(this_dir->de_name, "VIDEO_TS") != 0)		return val;	if (ts_number == 0) {		segment = 0;	} else {		if (name[4] >= '0' && name[4] <= '9'		 && name[5] >= '0' && name[5] <= '9'		 && name[6] == '_'		 && name[7] >= '0' && name[7] <= '9')		{			ts_number = name[4] * 10 + name[5] - ('0' * 11);			segment = name[7] - '0';		} else {			return val;		}	}	if (strcmp(name+8, audio ? ".AOB" : ".VOB") == 0) {		return audio * 10000 - ts_number * 12 - segment + 11198;	} else if (strcmp(name+8, ".IFO") == 0) {		return audio * 10000 - ts_number * 12 + 11199;	} else if (strcmp(name+8, ".BUP") == 0) {		return audio * 10000 - ts_number * 12 + 11188;	} else {		return val;	}}#endif  /* UDF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -