Handling of iso directory depth restrictions on tree creation time.
Note that this doesn't involve the RR reparent. It just ignore the files that break iso restrictions (see ECMA-119, 6.8.2.1).
This commit is contained in:
parent
0a340c53d5
commit
411524c330
@ -12,12 +12,13 @@
|
|||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "filesrc.h"
|
#include "filesrc.h"
|
||||||
|
#include "messages.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static
|
static
|
||||||
int set_iso_name(Ecma119Image *img, IsoNode *iso, Ecma119Node *node)
|
int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *ascii_name;
|
char *ascii_name;
|
||||||
@ -47,14 +48,13 @@ int set_iso_name(Ecma119Image *img, IsoNode *iso, Ecma119Node *node)
|
|||||||
iso_2_fileid(ascii_name);
|
iso_2_fileid(ascii_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node->iso_name = ascii_name;
|
*name = ascii_name;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node)
|
int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
Ecma119Node *ecma;
|
Ecma119Node *ecma;
|
||||||
|
|
||||||
ecma = calloc(1, sizeof(Ecma119Node));
|
ecma = calloc(1, sizeof(Ecma119Node));
|
||||||
@ -62,12 +62,6 @@ int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node)
|
|||||||
return ISO_MEM_ERROR;
|
return ISO_MEM_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = set_iso_name(img, iso, ecma);
|
|
||||||
if (ret < 0) {
|
|
||||||
free(ecma);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* take a ref to the IsoNode */
|
/* take a ref to the IsoNode */
|
||||||
ecma->node = iso;
|
ecma->node = iso;
|
||||||
iso_node_ref(iso);
|
iso_node_ref(iso);
|
||||||
@ -157,10 +151,13 @@ void ecma119_node_free(Ecma119Node *node)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree)
|
int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
||||||
|
int depth, int pathlen)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
Ecma119Node *node;
|
Ecma119Node *node;
|
||||||
|
int max_path;
|
||||||
|
char *iso_name = NULL;
|
||||||
|
|
||||||
if (image == NULL || iso == NULL || tree == NULL) {
|
if (image == NULL || iso == NULL || tree == NULL) {
|
||||||
return ISO_NULL_POINTER;
|
return ISO_NULL_POINTER;
|
||||||
@ -170,6 +167,21 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree)
|
|||||||
/* file will be ignored */
|
/* file will be ignored */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
ret = get_iso_name(image, iso, &iso_name);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
|
||||||
|
if (1) { //TODO !rockridge && !relaxed_paths
|
||||||
|
if (depth > 8 || max_path > 255) {
|
||||||
|
// char msg[512];
|
||||||
|
// sprintf(msg, "File %s can't be added, because depth > 8 "
|
||||||
|
// "or path length over 255\n", iso_name);
|
||||||
|
// iso_msg_note(image, LIBISO_FILE_IGNORED, msg);
|
||||||
|
free(iso_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(iso->type) {
|
switch(iso->type) {
|
||||||
case LIBISO_FILE:
|
case LIBISO_FILE:
|
||||||
@ -198,11 +210,11 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree)
|
|||||||
pos = dir->children;
|
pos = dir->children;
|
||||||
while (pos) {
|
while (pos) {
|
||||||
Ecma119Node *child;
|
Ecma119Node *child;
|
||||||
ret = create_tree(image, pos, &child);
|
ret = create_tree(image, pos, &child, depth + 1, max_path);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
ecma119_node_free(node);
|
ecma119_node_free(node);
|
||||||
return ret;
|
break;
|
||||||
} else if (ret == ISO_SUCCESS) {
|
} else if (ret == ISO_SUCCESS) {
|
||||||
/* add child to this node */
|
/* add child to this node */
|
||||||
int nchildren = node->info.dir.nchildren++;
|
int nchildren = node->info.dir.nchildren++;
|
||||||
@ -218,8 +230,10 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree)
|
|||||||
return ISO_ERROR;
|
return ISO_ERROR;
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
free(iso_name);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
node->iso_name = iso_name;
|
||||||
*tree = node;
|
*tree = node;
|
||||||
return ISO_SUCCESS;
|
return ISO_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -227,14 +241,14 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree)
|
|||||||
int ecma119_tree_create(Ecma119Image *img, IsoNode *iso, Ecma119Node **tree)
|
int ecma119_tree_create(Ecma119Image *img, IsoNode *iso, Ecma119Node **tree)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = create_tree(img, iso, tree);
|
ret = create_tree(img, iso, tree, 1, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO
|
* TODO
|
||||||
* - take care about dirs whose level is over 8
|
* - reparent if RR
|
||||||
* - sort files in dir
|
* - sort files in dir
|
||||||
* - mangle names
|
* - mangle names
|
||||||
*/
|
*/
|
||||||
|
@ -382,6 +382,9 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Range "vreixo" : 0x00030000 to 0x0003ffff
|
Range "vreixo" : 0x00030000 to 0x0003ffff
|
||||||
|
|
||||||
|
Image creation:
|
||||||
|
0x00030100 (NOTE,MEDIUM) = File cannot be added to image (ignored)
|
||||||
|
|
||||||
General:
|
General:
|
||||||
0x00031001 (SORRY,HIGH) = Cannot read file (ignored)
|
0x00031001 (SORRY,HIGH) = Cannot read file (ignored)
|
||||||
0x00031002 (FATAL,HIGH) = Cannot read file (operation canceled)
|
0x00031002 (FATAL,HIGH) = Cannot read file (operation canceled)
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
#include "libiso_msgs.h"
|
#include "libiso_msgs.h"
|
||||||
|
|
||||||
|
/** File cannot be added to image (ignored) */
|
||||||
|
#define LIBISO_FILE_IGNORED 0x00030100
|
||||||
|
|
||||||
/** Can't read file (ignored) */
|
/** Can't read file (ignored) */
|
||||||
#define LIBISO_CANT_READ_FILE 0x00031001
|
#define LIBISO_CANT_READ_FILE 0x00031001
|
||||||
/** Can't read file (operation canceled) */
|
/** Can't read file (operation canceled) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user