| 1 |
--- cdrkit-1.1.11.old/genisoimage/tree.c 2008-10-21 19:57:47.000000000 -0400 |
| 2 |
+++ cdrkit-1.1.11/genisoimage/tree.c 2013-12-06 00:23:18.489622668 -0500 |
| 3 |
@@ -1139,8 +1139,9 @@ |
| 4 |
scan_directory_tree(struct directory *this_dir, char *path, |
| 5 |
struct directory_entry *de) |
| 6 |
{ |
| 7 |
- DIR *current_dir; |
| 8 |
+ int current_file; |
| 9 |
char whole_path[PATH_MAX]; |
| 10 |
+ struct dirent **d_list; |
| 11 |
struct dirent *d_entry; |
| 12 |
struct directory *parent; |
| 13 |
int dflag; |
| 14 |
@@ -1164,7 +1165,8 @@ |
| 15 |
this_dir->dir_flags |= DIR_WAS_SCANNED; |
| 16 |
|
| 17 |
errno = 0; /* Paranoia */ |
| 18 |
- current_dir = opendir(path); |
| 19 |
+ //current_dir = opendir(path); |
| 20 |
+ current_file = scandir(path, &d_list, NULL, alphasort); |
| 21 |
d_entry = NULL; |
| 22 |
|
| 23 |
/* |
| 24 |
@@ -1173,12 +1175,12 @@ |
| 25 |
*/ |
| 26 |
old_path = path; |
| 27 |
|
| 28 |
- if (current_dir) { |
| 29 |
+ if (current_file >= 0) { |
| 30 |
errno = 0; |
| 31 |
- d_entry = readdir(current_dir); |
| 32 |
+ d_entry = d_list[0]; |
| 33 |
} |
| 34 |
|
| 35 |
- if (!current_dir || !d_entry) { |
| 36 |
+ if (current_file < 0 || !d_entry) { |
| 37 |
int ret = 1; |
| 38 |
|
| 39 |
#ifdef USE_LIBSCHILY |
| 40 |
@@ -1191,8 +1193,8 @@ |
| 41 |
de->isorec.flags[0] &= ~ISO_DIRECTORY; |
| 42 |
ret = 0; |
| 43 |
} |
| 44 |
- if (current_dir) |
| 45 |
- closedir(current_dir); |
| 46 |
+ if(d_list) |
| 47 |
+ free(d_list); |
| 48 |
return (ret); |
| 49 |
} |
| 50 |
#ifdef ABORT_DEEP_ISO_ONLY |
| 51 |
@@ -1208,7 +1210,7 @@ |
| 52 |
errmsgno(EX_BAD, "use Rock Ridge extensions via -R or -r,\n"); |
| 53 |
errmsgno(EX_BAD, "or allow deep ISO9660 directory nesting via -D.\n"); |
| 54 |
} |
| 55 |
- closedir(current_dir); |
| 56 |
+ free(d_list); |
| 57 |
return (1); |
| 58 |
} |
| 59 |
#endif |
| 60 |
@@ -1250,13 +1252,13 @@ |
| 61 |
* The first time through, skip this, since we already asked |
| 62 |
* for the first entry when we opened the directory. |
| 63 |
*/ |
| 64 |
- if (dflag) |
| 65 |
- d_entry = readdir(current_dir); |
| 66 |
+ if (dflag && current_file >= 0) |
| 67 |
+ d_entry = d_list[current_file]; |
| 68 |
dflag++; |
| 69 |
|
| 70 |
- if (!d_entry) |
| 71 |
+ if (current_file < 0) |
| 72 |
break; |
| 73 |
- |
| 74 |
+ current_file--; |
| 75 |
/* OK, got a valid entry */ |
| 76 |
|
| 77 |
/* If we do not want all files, then pitch the backups. */ |
| 78 |
@@ -1348,7 +1350,7 @@ |
| 79 |
insert_file_entry(this_dir, whole_path, d_entry->d_name); |
| 80 |
#endif /* APPLE_HYB */ |
| 81 |
} |
| 82 |
- closedir(current_dir); |
| 83 |
+ free(d_list); |
| 84 |
|
| 85 |
#ifdef APPLE_HYB |
| 86 |
/* |