@@ -1205,9 +1205,16 @@ int traverse_xiso( int in_xiso, dir_node *in_dir_node, xoff_t in_dir_start, char
1205
1205
1206
1206
if ( ! err ) {
1207
1207
if ( tmp == XISO_PAD_SHORT ) {
1208
+ if ( l_offset == 0 ) { // Directory is empty
1209
+ if (in_mode == k_generate_avl ) {
1210
+ avl_insert (in_root , EMPTY_SUBDIRECTORY );
1211
+ }
1212
+ goto end_traverse ;
1213
+ }
1214
+
1208
1215
l_offset = l_offset * XISO_DWORD_SIZE + ( XISO_SECTOR_SIZE - ( l_offset * XISO_DWORD_SIZE ) % XISO_SECTOR_SIZE );
1209
1216
err = lseek ( in_xiso , in_dir_start + (xoff_t ) l_offset , SEEK_SET ) == -1 ? 1 : 0 ;
1210
-
1217
+
1211
1218
if ( ! err ) goto read_entry ; // me and my silly comments
1212
1219
} else {
1213
1220
l_offset = tmp ;
@@ -1254,7 +1261,7 @@ int traverse_xiso( int in_xiso, dir_node *in_dir_node, xoff_t in_dir_start, char
1254
1261
1255
1262
avl -> file_size = dir -> file_size ;
1256
1263
avl -> old_start_sector = dir -> start_sector ;
1257
-
1264
+
1258
1265
if ( avl_insert ( in_root , avl ) == k_avl_error ) misc_err ( "this iso appears to be corrupt\n" , 0 , 0 , 0 );
1259
1266
}
1260
1267
}
@@ -1299,7 +1306,10 @@ int traverse_xiso( int in_xiso, dir_node *in_dir_node, xoff_t in_dir_start, char
1299
1306
if ( ( err = mkdir ( dir -> filename , 0755 ) ) ) mkdir_err ( dir -> filename );
1300
1307
if ( ! err && dir -> start_sector && ( err = chdir ( dir -> filename ) ) ) chdir_err ( dir -> filename );
1301
1308
}
1302
- if ( ! err && in_mode != k_list && in_mode != k_generate_avl ) exiso_log ( "creating %s (0 bytes) [OK]\n" , path );
1309
+ if ( ! err && in_mode != k_generate_avl ) {
1310
+ exiso_log ("%s%s%s%s (0 bytes)" , in_mode == k_extract ? "creating " : "" , in_path , dir -> filename , PATH_CHAR_STR ); flush ();
1311
+ exiso_log ("\n" );
1312
+ }
1303
1313
}
1304
1314
}
1305
1315
@@ -1352,6 +1362,8 @@ int traverse_xiso( int in_xiso, dir_node *in_dir_node, xoff_t in_dir_start, char
1352
1362
}
1353
1363
}
1354
1364
1365
+ end_traverse :
1366
+
1355
1367
if ( dir -> filename ) free ( dir -> filename );
1356
1368
1357
1369
if ( ( dir = dir -> parent ) ) goto left_processed ;
@@ -1725,6 +1737,10 @@ int write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int in_dep
1725
1737
}
1726
1738
1727
1739
if ( context .path ) free ( context .path );
1740
+ } else {
1741
+ memset (sector , XISO_PAD_BYTE , XISO_SECTOR_SIZE );
1742
+ if ((pos = lseek (in_context -> xiso , in_avl -> start_sector * XISO_SECTOR_SIZE , SEEK_SET )) == -1 ) seek_err ();
1743
+ if (!err && write (in_context -> xiso , sector , XISO_SECTOR_SIZE ) != XISO_SECTOR_SIZE ) write_err ();
1728
1744
}
1729
1745
}
1730
1746
}
@@ -1841,7 +1857,11 @@ int calculate_directory_offsets( dir_node_avl *in_avl, unsigned long *io_current
1841
1857
wdsafp_context context ;
1842
1858
1843
1859
if ( in_avl -> subdirectory ) {
1844
- if ( in_avl -> subdirectory == EMPTY_SUBDIRECTORY ) in_avl -> start_sector = 0 ;
1860
+ if (in_avl -> subdirectory == EMPTY_SUBDIRECTORY ) {
1861
+ in_avl -> start_sector = * io_current_sector ;
1862
+ in_avl -> file_size = XISO_SECTOR_SIZE ;
1863
+ * io_current_sector += 1 ;
1864
+ }
1845
1865
else {
1846
1866
context .current_sector = io_current_sector ;
1847
1867
context .dir_start = (xoff_t ) ( in_avl -> start_sector = * io_current_sector ) * XISO_SECTOR_SIZE ;
@@ -1873,6 +1893,8 @@ int calculate_total_files_and_bytes( dir_node_avl *in_avl, void *in_context, int
1873
1893
if ( in_avl -> subdirectory ) {
1874
1894
if ( in_avl -> subdirectory != EMPTY_SUBDIRECTORY ) {
1875
1895
avl_traverse_depth_first ( in_avl -> subdirectory , (traversal_callback ) calculate_total_files_and_bytes , nil , k_prefix , 0 );
1896
+ } else {
1897
+ s_total_bytes += XISO_SECTOR_SIZE ;
1876
1898
}
1877
1899
} else {
1878
1900
++ s_total_files ;
0 commit comments