Enhance support for relaxe ISO constraints.

This commit is contained in:
Vreixo Formoso 2008-01-15 00:21:07 +01:00
parent 9ad9b10c67
commit 9a66c6cd33
9 changed files with 63 additions and 6 deletions

View File

@ -12,6 +12,7 @@
#include "filesrc.h" #include "filesrc.h"
#include "node.h" #include "node.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -41,7 +42,7 @@ static void
print_dir(Ecma119Node *dir, int level) print_dir(Ecma119Node *dir, int level)
{ {
int i; int i;
char sp[level * 2 + 1]; char *sp = alloca(level * 2 + 1);
for (i = 0; i < level * 2; i += 2) { for (i = 0; i < level * 2; i += 2) {
sp[i] = '|'; sp[i] = '|';

View File

@ -55,6 +55,7 @@ int main(int argc, char **argv)
0, /* joliet */ 0, /* joliet */
0, /* omit_version_numbers */ 0, /* omit_version_numbers */
0, /* allow_deep_paths */ 0, /* allow_deep_paths */
0, /* allow_longer_paths */
0, /* max_37_char_filenames */ 0, /* max_37_char_filenames */
0, /* no_force_dots */ 0, /* no_force_dots */
0, /* allow_lowercase */ 0, /* allow_lowercase */

View File

@ -38,6 +38,7 @@ int main(int argc, char **argv)
0, /* joliet */ 0, /* joliet */
0, /* omit_version_numbers */ 0, /* omit_version_numbers */
0, /* allow_deep_paths */ 0, /* allow_deep_paths */
0, /* allow_longer_paths */
0, /* max_37_char_filenames */ 0, /* max_37_char_filenames */
0, /* no_force_dots */ 0, /* no_force_dots */
0, /* allow_lowercase */ 0, /* allow_lowercase */

View File

@ -33,6 +33,7 @@ int main(int argc, char **argv)
0, /* joliet */ 0, /* joliet */
0, /* omit_version_numbers */ 0, /* omit_version_numbers */
0, /* allow_deep_paths */ 0, /* allow_deep_paths */
0, /* allow_longer_paths */
0, /* max_37_char_filenames */ 0, /* max_37_char_filenames */
0, /* no_force_dots */ 0, /* no_force_dots */
0, /* allow_lowercase */ 0, /* allow_lowercase */

View File

@ -33,6 +33,7 @@ int main(int argc, char **argv)
0, /* joliet */ 0, /* joliet */
0, /* omit_version_numbers */ 0, /* omit_version_numbers */
0, /* allow_deep_paths */ 0, /* allow_deep_paths */
0, /* allow_longer_paths */
0, /* max_37_char_filenames */ 0, /* max_37_char_filenames */
0, /* no_force_dots */ 0, /* no_force_dots */
0, /* allow_lowercase */ 0, /* allow_lowercase */

View File

@ -847,6 +847,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
target->omit_version_numbers = opts->omit_version_numbers target->omit_version_numbers = opts->omit_version_numbers
| opts->max_37_char_filenames; | opts->max_37_char_filenames;
target->allow_deep_paths = opts->allow_deep_paths; target->allow_deep_paths = opts->allow_deep_paths;
target->allow_longer_paths = opts->allow_longer_paths;
target->max_37_char_filenames = opts->max_37_char_filenames; target->max_37_char_filenames = opts->max_37_char_filenames;
target->no_force_dots = opts->no_force_dots; target->no_force_dots = opts->no_force_dots;
target->allow_lowercase = opts->allow_lowercase; target->allow_lowercase = opts->allow_lowercase;

View File

@ -39,6 +39,7 @@ struct ecma119_image
/* relaxed constraints */ /* relaxed constraints */
unsigned int omit_version_numbers :1; unsigned int omit_version_numbers :1;
unsigned int allow_deep_paths :1; unsigned int allow_deep_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 :1;
unsigned int allow_lowercase :1; unsigned int allow_lowercase :1;

View File

@ -296,11 +296,17 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
return ret; return ret;
} }
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0); max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
if (!image->rockridge && !image->allow_deep_paths) { if (!image->rockridge) {
if ((iso->type == LIBISO_DIR && depth > 8) || max_path > 255) { if ((iso->type == LIBISO_DIR && depth > 8) && !image->allow_deep_paths) {
iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED, iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" can't be added, because depth > 8 " "File \"%s\" can't be added, because directory depth "
"or path length over 255", iso->name); "is greater than 8.", iso->name);
free(iso_name);
return 0;
} else if (max_path > 255 && !image->allow_longer_paths) {
iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED,
"File \"%s\" can't be added, because path length "
"is greater than 255 characters", iso->name);
free(iso_name); free(iso_name);
return 0; return 0;
} }

View File

@ -100,13 +100,57 @@ typedef struct
unsigned int rockridge :1; unsigned int rockridge :1;
unsigned int joliet :1; unsigned int joliet :1;
/* relaxed constraints */ /*
* Relaxed constraints. Setting any of these to 1 break the specifications,
* but it is supposed to work on most moderns systems. Use with caution.
*/
/**
* Omit the version number (";1") at the end of the ISO-9660 identifiers.
* Version numbers are usually not used.
*/
unsigned int omit_version_numbers :1; unsigned int omit_version_numbers :1;
/**
* Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
*/
unsigned int allow_deep_paths :1; unsigned int allow_deep_paths :1;
/**
* Allow path in the ISO-9660 tree to have more than 255 characters.
*/
unsigned int allow_longer_paths :1;
/**
* Allow a single file or directory hierarchy to have up to 37 characters.
* This is larger than the 31 characters allowed by ISO level 2, and the
* extra space is taken from the version number, so this also forces
* omit_version_numbers.
*/
unsigned int max_37_char_filenames :1; unsigned int max_37_char_filenames :1;
/**
* ISO-9660 forces filenames to have a ".", that separates file name from
* extension. libisofs adds it if original filename doesn't has one. Set
* this to 1 to prevent this behavior
*/
unsigned int no_force_dots :1; unsigned int no_force_dots :1;
/**
* Allow lowercase characters in ISO-9660 filenames. By default, only
* uppercase characters, numbers and a few other characters are allowed.
*/
unsigned int allow_lowercase :1; unsigned int allow_lowercase :1;
/**
* Allow all ASCII characters to be appear on an ISO-9660 filename. Note
* that "/" and "\0" characters are never allowed, even in RR names.
*/
unsigned int allow_full_ascii :1; unsigned int allow_full_ascii :1;
/**
* Allow paths in the Joliet tree to have more than 240 characters.
*/
unsigned int joliet_longer_paths :1; unsigned int joliet_longer_paths :1;
/**< If files should be sorted based on their weight. */ /**< If files should be sorted based on their weight. */