Support charset conversion on symlink destination.
This commit is contained in:
parent
c47e5a738d
commit
6298ef4814
@ -894,7 +894,22 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO convert link destinatiion to needed charset
|
/* convert link destination to needed charset */
|
||||||
|
if (strcmp(fsdata->input_charset, fsdata->local_charset) && linkdest) {
|
||||||
|
/* we need to convert name charset */
|
||||||
|
char *newlinkdest = NULL;
|
||||||
|
ret = strconv(linkdest, fsdata->input_charset,
|
||||||
|
fsdata->local_charset, &newlinkdest);
|
||||||
|
if (ret < 0) {
|
||||||
|
iso_msg_sorry(fsdata->messenger, LIBISO_CHARSET_ERROR,
|
||||||
|
"Charset conversion error. Can't convert %s from %s to %s",
|
||||||
|
linkdest, fsdata->input_charset, fsdata->local_charset);
|
||||||
|
free(newlinkdest);
|
||||||
|
} else {
|
||||||
|
free(linkdest);
|
||||||
|
linkdest = newlinkdest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* RR extensions are not read / used */
|
/* RR extensions are not read / used */
|
||||||
|
@ -248,25 +248,29 @@ int rrip_add_CL(Ecma119Image *t, Ecma119Node *n, struct susp_info *susp)
|
|||||||
return susp_append(t, susp, CL);
|
return susp_append(t, susp, CL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a RR filename to the requested charset. On any conversion error,
|
||||||
|
* the original name will be used.
|
||||||
|
*/
|
||||||
static
|
static
|
||||||
char *get_rr_name(Ecma119Image *t, Ecma119Node *n)
|
char *get_rr_fname(Ecma119Image *t, const char *str)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (!strcmp(t->input_charset, t->output_charset)) {
|
if (!strcmp(t->input_charset, t->output_charset)) {
|
||||||
/* no conversion needed */
|
/* no conversion needed */
|
||||||
return strdup(n->node->name);
|
return strdup(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = strconv(n->node->name, t->input_charset, t->output_charset, &name);
|
ret = strconv(str, t->input_charset, t->output_charset, &name);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
iso_msg_sorry(t->image->messenger, LIBISO_CHARSET_ERROR,
|
iso_msg_sorry(t->image->messenger, LIBISO_CHARSET_ERROR,
|
||||||
"Charset conversion error. Can't convert %s from %s to %s",
|
"Charset conversion error. Can't convert %s from %s to %s",
|
||||||
n->node->name, t->input_charset, t->output_charset);
|
str, t->input_charset, t->output_charset);
|
||||||
|
|
||||||
/* use the original name, it's the best we can do */
|
/* use the original name, it's the best we can do */
|
||||||
name = strdup(n->node->name);
|
name = strdup(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
@ -569,7 +573,7 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type == 0) {
|
if (type == 0) {
|
||||||
char *name = get_rr_name(t, n);
|
char *name = get_rr_fname(t, n->node->name);
|
||||||
size_t namelen = strlen(name);
|
size_t namelen = strlen(name);
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
@ -587,11 +591,12 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
|||||||
/*
|
/*
|
||||||
* for symlinks, we also need to write the SL
|
* for symlinks, we also need to write the SL
|
||||||
*/
|
*/
|
||||||
char *cur, *prev;
|
char *dest, *cur, *prev;
|
||||||
size_t sl_len = 5;
|
size_t sl_len = 5;
|
||||||
int cew = (*ce != 0); /* are we writing to CE? */
|
int cew = (*ce != 0); /* are we writing to CE? */
|
||||||
|
|
||||||
prev = ((IsoSymlink*)n->node)->dest;
|
dest = get_rr_fname(t, ((IsoSymlink*)n->node)->dest);
|
||||||
|
prev = dest;
|
||||||
cur = strchr(prev, '/');
|
cur = strchr(prev, '/');
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t clen;
|
size_t clen;
|
||||||
@ -680,6 +685,8 @@ size_t rrip_calc_len(Ecma119Image *t, Ecma119Node *n, int type, size_t space,
|
|||||||
cur = strchr(prev, '/');
|
cur = strchr(prev, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(dest);
|
||||||
|
|
||||||
/* and finally write the pending SL field */
|
/* and finally write the pending SL field */
|
||||||
if (!cew) {
|
if (!cew) {
|
||||||
/* the whole SL fits into the SUA */
|
/* the whole SL fits into the SUA */
|
||||||
@ -755,6 +762,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
size_t i;
|
size_t i;
|
||||||
Ecma119Node *node;
|
Ecma119Node *node;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
char *dest = NULL;
|
||||||
|
|
||||||
if (t == NULL || n == NULL || info == NULL) {
|
if (t == NULL || n == NULL || info == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
@ -844,7 +852,7 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
uint8_t **comps= NULL; /* components of the SL field */
|
uint8_t **comps= NULL; /* components of the SL field */
|
||||||
size_t n_comp = 0; /* number of components */
|
size_t n_comp = 0; /* number of components */
|
||||||
|
|
||||||
name = get_rr_name(t, n);
|
name = get_rr_fname(t, n->node->name);
|
||||||
namelen = strlen(name);
|
namelen = strlen(name);
|
||||||
|
|
||||||
sua_free = space - info->suf_len;
|
sua_free = space - info->suf_len;
|
||||||
@ -869,7 +877,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
size_t sl_len = 5;
|
size_t sl_len = 5;
|
||||||
int cew = (nm_type == 1); /* are we writing to CE? */
|
int cew = (nm_type == 1); /* are we writing to CE? */
|
||||||
|
|
||||||
prev = ((IsoSymlink*)n->node)->dest;
|
dest = get_rr_fname(t, ((IsoSymlink*)n->node)->dest);
|
||||||
|
prev = dest;
|
||||||
cur = strchr(prev, '/');
|
cur = strchr(prev, '/');
|
||||||
while (1) {
|
while (1) {
|
||||||
size_t clen;
|
size_t clen;
|
||||||
@ -1107,10 +1116,12 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
|
|||||||
info->suf_len += (info->suf_len % 2);
|
info->suf_len += (info->suf_len % 2);
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
free(dest);
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
|
|
||||||
add_susp_cleanup: ;
|
add_susp_cleanup: ;
|
||||||
free(name);
|
free(name);
|
||||||
|
free(dest);
|
||||||
susp_info_free(info);
|
susp_info_free(info);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user