Different function for generate dir and files names for Joliet.

The "." is not mandatory on dirs.
release-1.5.4.branch
Vreixo Formoso 15 years ago
parent f73b53133b
commit 5475502dc8
  1. 9
      src/joliet.c
  2. 29
      src/util.c
  3. 19
      src/util.h

@ -36,7 +36,11 @@ int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
}
// TODO add support for relaxed constraints
jname = iso_j_id(ucs_name);
if (iso->type == LIBISO_DIR) {
jname = iso_j_dir_id(ucs_name);
} else {
jname = iso_j_file_id(ucs_name);
}
free(ucs_name);
if (jname != NULL) {
*name = jname;
@ -125,6 +129,7 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
joliet->node = iso;
iso_node_ref(iso);
*node = joliet;
return ISO_SUCCESS;
}
@ -138,7 +143,7 @@ static
int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
{
int ret, max_path;
JolietNode *node;
JolietNode *node = NULL;
uint16_t *jname = NULL;
if (t == NULL || iso == NULL || tree == NULL) {

@ -491,11 +491,11 @@ char *iso_2_fileid(const char *src)
return strdup(dest);
}
uint16_t *iso_j_id(const uint16_t *src)
uint16_t *iso_j_file_id(const uint16_t *src)
{
uint16_t *dot;
size_t lname, lext, lnname, lnext, pos, i;
uint16_t dest[66]; /* 65 = 64 (name + ext) + 1 (.) + 1 (\0) */
uint16_t dest[66]; /* 66 = 64 (name + ext) + 1 (.) + 1 (\0) */
if (src == NULL) {
return NULL;
@ -554,6 +554,31 @@ uint16_t *iso_j_id(const uint16_t *src)
return ucsdup(dest);
}
uint16_t *iso_j_dir_id(const uint16_t *src)
{
size_t len, i;
uint16_t dest[65]; /* 65 = 64 + 1 (\0) */
if (src == NULL) {
return NULL;
}
len = ucslen(src);
if (len > 64) {
len = 64;
}
for (i = 0; i < len; i++) {
uint16_t c = src[i];
if (valid_j_char(c)) {
dest[i] = c;
} else {
set_ucsbe(dest + i, '_');
}
}
set_ucsbe(dest + len, '\0');
return ucsdup(dest);
}
size_t ucslen(const uint16_t *str)
{
size_t i;

@ -114,9 +114,9 @@ char *iso_1_fileid(const char *src);
char *iso_2_fileid(const char *src);
/**
* Create a Joliet file or directory identifier that consists of name and
* extension. The combined name and extension length will not exceed 128 bytes,
* and the name and extension will be separated (.). All characters consist of
* Create a Joliet file identifier that consists of name and extension. The
* combined name and extension length will not exceed 128 bytes, and the
* name and extension will be separated (.). All characters consist of
* 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.
*
* Note that version number and (;1) is not appended.
@ -124,7 +124,18 @@ char *iso_2_fileid(const char *src);
* @return
* NULL if the original name and extension both are of length 0.
*/
uint16_t *iso_j_id(const uint16_t *src);
uint16_t *iso_j_file_id(const uint16_t *src);
/**
* Create a Joliet directory identifier that consists of name and optionally
* extension. The combined name and extension length will not exceed 128 bytes,
* and the name and extension will be separated (.). All characters consist of
* 2 bytes and the resulting string is NULL-terminated by a 2-byte NULL.
*
* @return
* NULL if the original name and extension both are of length 0.
*/
uint16_t *iso_j_dir_id(const uint16_t *src);
/**
* Like strlen, but for Joliet strings.

Loading…
Cancel
Save