Implemented no_force_dots and separate omit_version_numbers for
Joliet to allow producing the same Joliet names as mkisofs -J.
This commit is contained in:
parent
b089f2e978
commit
016baf9984
@ -96,7 +96,7 @@ void ecma119_image_free(Ecma119Image *t)
|
|||||||
static
|
static
|
||||||
int need_version_number(Ecma119Image *t, Ecma119Node *n)
|
int need_version_number(Ecma119Image *t, Ecma119Node *n)
|
||||||
{
|
{
|
||||||
if (t->omit_version_numbers) {
|
if (t->omit_version_numbers & 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (n->type == ECMA119_DIR || n->type == ECMA119_PLACEHOLDER) {
|
if (n->type == ECMA119_DIR || n->type == ECMA119_PLACEHOLDER) {
|
||||||
@ -1821,7 +1821,7 @@ int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit)
|
|||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
}
|
}
|
||||||
opts->omit_version_numbers = omit ? 1 : 0;
|
opts->omit_version_numbers = omit & 3;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1857,7 +1857,7 @@ int iso_write_opts_set_no_force_dots(IsoWriteOpts *opts, int no)
|
|||||||
if (opts == NULL) {
|
if (opts == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
}
|
}
|
||||||
opts->no_force_dots = no ? 1 : 0;
|
opts->no_force_dots = no & 3;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,10 @@ struct iso_write_opts {
|
|||||||
/**
|
/**
|
||||||
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
|
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
|
||||||
* Version numbers are usually not used.
|
* Version numbers are usually not used.
|
||||||
|
* bit0= ECMA-119 and Joliet (for historical reasons)
|
||||||
|
* bit1= Joliet
|
||||||
*/
|
*/
|
||||||
unsigned int omit_version_numbers :1;
|
unsigned int omit_version_numbers :2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
|
* Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
|
||||||
@ -82,8 +84,10 @@ struct iso_write_opts {
|
|||||||
* ISO-9660 forces filenames to have a ".", that separates file name from
|
* ISO-9660 forces filenames to have a ".", that separates file name from
|
||||||
* extension. libisofs adds it if original filename doesn't has one. Set
|
* extension. libisofs adds it if original filename doesn't has one. Set
|
||||||
* this to 1 to prevent this behavior
|
* this to 1 to prevent this behavior
|
||||||
|
* bit0= ECMA-119
|
||||||
|
* bit1= Joliet
|
||||||
*/
|
*/
|
||||||
unsigned int no_force_dots :1;
|
unsigned int no_force_dots :2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow lowercase characters in ISO-9660 filenames. By default, only
|
* Allow lowercase characters in ISO-9660 filenames. By default, only
|
||||||
@ -344,11 +348,11 @@ struct ecma119_image
|
|||||||
unsigned int always_gmt :1;
|
unsigned int always_gmt :1;
|
||||||
|
|
||||||
/* relaxed constraints */
|
/* relaxed constraints */
|
||||||
unsigned int omit_version_numbers :1;
|
unsigned int omit_version_numbers :2;
|
||||||
unsigned int allow_deep_paths :1;
|
unsigned int allow_deep_paths :1;
|
||||||
unsigned int allow_longer_paths :1;
|
unsigned int allow_longer_paths :1;
|
||||||
unsigned int max_37_char_filenames :1;
|
unsigned int max_37_char_filenames :1;
|
||||||
unsigned int no_force_dots :1;
|
unsigned int no_force_dots :2;
|
||||||
unsigned int allow_lowercase :1;
|
unsigned int allow_lowercase :1;
|
||||||
unsigned int allow_full_ascii :1;
|
unsigned int allow_full_ascii :1;
|
||||||
|
|
||||||
|
@ -64,18 +64,18 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
|||||||
} else {
|
} else {
|
||||||
if (img->max_37_char_filenames) {
|
if (img->max_37_char_filenames) {
|
||||||
isoname = iso_r_fileid(ascii_name, 36, relaxed,
|
isoname = iso_r_fileid(ascii_name, 36, relaxed,
|
||||||
img->no_force_dots ? 0 : 1);
|
(img->no_force_dots & 1) ? 0 : 1);
|
||||||
} else if (img->iso_level == 1) {
|
} else if (img->iso_level == 1) {
|
||||||
if (relaxed) {
|
if (relaxed) {
|
||||||
isoname = iso_r_fileid(ascii_name, 11, relaxed,
|
isoname = iso_r_fileid(ascii_name, 11, relaxed,
|
||||||
img->no_force_dots ? 0 : 1);
|
(img->no_force_dots & 1) ? 0 : 1);
|
||||||
} else {
|
} else {
|
||||||
isoname = iso_1_fileid(ascii_name);
|
isoname = iso_1_fileid(ascii_name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (relaxed) {
|
if (relaxed) {
|
||||||
isoname = iso_r_fileid(ascii_name, 30, relaxed,
|
isoname = iso_r_fileid(ascii_name, 30, relaxed,
|
||||||
img->no_force_dots ? 0 : 1);
|
(img->no_force_dots & 1) ? 0 : 1);
|
||||||
} else {
|
} else {
|
||||||
isoname = iso_2_fileid(ascii_name);
|
isoname = iso_2_fileid(ascii_name);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
|
|||||||
if (iso->type == LIBISO_DIR) {
|
if (iso->type == LIBISO_DIR) {
|
||||||
jname = iso_j_dir_id(ucs_name);
|
jname = iso_j_dir_id(ucs_name);
|
||||||
} else {
|
} else {
|
||||||
jname = iso_j_file_id(ucs_name);
|
jname = iso_j_file_id(ucs_name, !!(t->no_force_dots & 2));
|
||||||
}
|
}
|
||||||
free(ucs_name);
|
free(ucs_name);
|
||||||
if (jname != NULL) {
|
if (jname != NULL) {
|
||||||
@ -574,7 +574,7 @@ size_t calc_dirent_len(Ecma119Image *t, JolietNode *n)
|
|||||||
{
|
{
|
||||||
/* note than name len is always even, so we always need the pad byte */
|
/* note than name len is always even, so we always need the pad byte */
|
||||||
int ret = n->name ? ucslen(n->name) * 2 + 34 : 34;
|
int ret = n->name ? ucslen(n->name) * 2 + 34 : 34;
|
||||||
if (n->type == JOLIET_FILE && !t->omit_version_numbers) {
|
if (n->type == JOLIET_FILE && !(t->omit_version_numbers & 3)) {
|
||||||
/* take into account version numbers */
|
/* take into account version numbers */
|
||||||
ret += 4;
|
ret += 4;
|
||||||
}
|
}
|
||||||
@ -722,7 +722,7 @@ void write_one_dir_record(Ecma119Image *t, JolietNode *node, int file_id,
|
|||||||
|
|
||||||
memcpy(rec->file_id, name, len_fi);
|
memcpy(rec->file_id, name, len_fi);
|
||||||
|
|
||||||
if (node->type == JOLIET_FILE && !t->omit_version_numbers) {
|
if (node->type == JOLIET_FILE && !(t->omit_version_numbers & 3)) {
|
||||||
len_dr += 4;
|
len_dr += 4;
|
||||||
rec->file_id[len_fi++] = 0;
|
rec->file_id[len_fi++] = 0;
|
||||||
rec->file_id[len_fi++] = ';';
|
rec->file_id[len_fi++] = ';';
|
||||||
@ -899,7 +899,7 @@ int write_one_dir(Ecma119Image *t, JolietNode *dir)
|
|||||||
/* compute len of directory entry */
|
/* compute len of directory entry */
|
||||||
fi_len = ucslen(child->name) * 2;
|
fi_len = ucslen(child->name) * 2;
|
||||||
len = fi_len + 34;
|
len = fi_len + 34;
|
||||||
if (child->type == JOLIET_FILE && !t->omit_version_numbers) {
|
if (child->type == JOLIET_FILE && !(t->omit_version_numbers & 3)) {
|
||||||
len += 4;
|
len += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,7 +1286,9 @@ int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable);
|
|||||||
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
|
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
|
||||||
* This breaks ECMA-119 specification, but version numbers are usually not
|
* This breaks ECMA-119 specification, but version numbers are usually not
|
||||||
* used, so it should work on most systems. Use with caution.
|
* used, so it should work on most systems. Use with caution.
|
||||||
*
|
* @param omit
|
||||||
|
* bit0= omit version number with ECMA-119 and Joliet
|
||||||
|
* bit1= omit version number with Joliet alone (@since 0.6.30)
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit);
|
int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit);
|
||||||
@ -1324,6 +1326,9 @@ int iso_write_opts_set_max_37_char_filenames(IsoWriteOpts *opts, int allow);
|
|||||||
* extension. libisofs adds it if original filename doesn't has one. Set
|
* extension. libisofs adds it if original filename doesn't has one. Set
|
||||||
* this to 1 to prevent this behavior.
|
* this to 1 to prevent this behavior.
|
||||||
* This breaks ECMA-119 specification. Use with caution.
|
* This breaks ECMA-119 specification. Use with caution.
|
||||||
|
* @param no
|
||||||
|
* bit0= no forced dot with ECMA-119
|
||||||
|
* bit1= no forced dot with Joliet (@since 0.6.30)
|
||||||
*
|
*
|
||||||
* @since 0.6.2
|
* @since 0.6.2
|
||||||
*/
|
*/
|
||||||
|
@ -908,7 +908,10 @@ ex:;
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t *iso_j_file_id(const uint16_t *src)
|
/*
|
||||||
|
bit0= no_force_dots
|
||||||
|
*/
|
||||||
|
uint16_t *iso_j_file_id(const uint16_t *src, int flag)
|
||||||
{
|
{
|
||||||
uint16_t *dot;
|
uint16_t *dot;
|
||||||
size_t lname, lext, lnname, lnext, pos, i;
|
size_t lname, lext, lnname, lnext, pos, i;
|
||||||
@ -954,6 +957,10 @@ uint16_t *iso_j_file_id(const uint16_t *src)
|
|||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flag & 1) && lnext <= 0)
|
||||||
|
goto is_done;
|
||||||
|
|
||||||
set_ucsbe(dest + pos, '.');
|
set_ucsbe(dest + pos, '.');
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
@ -967,6 +974,8 @@ uint16_t *iso_j_file_id(const uint16_t *src)
|
|||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_done:;
|
||||||
set_ucsbe(dest + pos, '\0');
|
set_ucsbe(dest + pos, '\0');
|
||||||
return ucsdup(dest);
|
return ucsdup(dest);
|
||||||
}
|
}
|
||||||
|
@ -151,11 +151,12 @@ char *iso_r_fileid(const char *src, size_t len, int relaxed, int forcedot);
|
|||||||
* 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.
|
* 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.
|
||||||
*
|
*
|
||||||
* Note that version number and (;1) is not appended.
|
* Note that version number and (;1) is not appended.
|
||||||
*
|
* @param flag
|
||||||
|
* bit0= no_force_dots
|
||||||
* @return
|
* @return
|
||||||
* NULL if the original name and extension both are of length 0.
|
* NULL if the original name and extension both are of length 0.
|
||||||
*/
|
*/
|
||||||
uint16_t *iso_j_file_id(const uint16_t *src);
|
uint16_t *iso_j_file_id(const uint16_t *src, int flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Joliet directory identifier that consists of name and optionally
|
* Create a Joliet directory identifier that consists of name and optionally
|
||||||
|
Loading…
Reference in New Issue
Block a user