Skip to content

Rescue extract-xiso from oblivion #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a5857a3
Define exiso_warn macro, set 's_warned'
rapperskull Mar 4, 2023
90f0945
Rewrite traverse_xiso() to use recursion
rapperskull Mar 4, 2023
01f8bb1
Fix some warnings
rapperskull Mar 4, 2023
0b1804f
Replace all malloc+sprintf with asprintf
rapperskull Mar 4, 2023
c07d089
Rewrite path separation to use strrchr and avoid empty for loops
rapperskull Mar 5, 2023
b04abd0
Move all newlines to beginning of strings
rapperskull Mar 5, 2023
2e81f67
Fix: don't count empty subdirectories as files
rapperskull Mar 5, 2023
093f36a
Fix memory leak in write_tree
rapperskull Mar 5, 2023
c14ddce
Check before free
rapperskull Mar 6, 2023
4759c86
Add new strategy to list files in directory
rapperskull Mar 6, 2023
b9a36ea
Many fixes for directories with size 0
rapperskull Mar 6, 2023
2fda995
Fix integer overflow in write_tree
rapperskull Mar 6, 2023
54375af
Various changes for legibility
rapperskull Mar 7, 2023
ccc5373
Fixed bug that would not skip files >= 4 GiB
rapperskull Mar 4, 2023
8f4bb08
Fix a bug that would cause unnecessary overlapping writes for xbe fil…
rapperskull Mar 11, 2023
49e0f25
Fix some data types, reduce unnecessarly large buffer
rapperskull Mar 14, 2023
9c636dd
Fix lseek with wrapper that returns error when trying to seek past fi…
rapperskull Mar 14, 2023
5216be4
Use realpath/_fullpath to get absolute path of output dir
rapperskull Mar 15, 2023
9be2806
Fix compilation under FreeBSD, OpenBSD, MinGW and Cygwin/MSYS2, add s…
rapperskull Mar 11, 2023
a029894
Swallow the semicolon in function-like macros
rapperskull Mar 17, 2023
80e7d5d
Simplify free_dir_node_avl
rapperskull Mar 17, 2023
6928e89
Rewrite usage macro to include exit and print to stdout when using -h…
rapperskull Mar 17, 2023
3dd3297
Fix calculation of total size and files number across isos
rapperskull Mar 18, 2023
c9dacc3
Fix typo and spacing, use tabulation to align output
rapperskull Mar 19, 2023
c76c66a
Add const qualifiers where possible
rapperskull Mar 20, 2023
481ab8d
Simplify main a bit
rapperskull Mar 21, 2023
13e88af
Add alternative XGD2 offset
rapperskull Mar 27, 2023
64e7003
Add support for Unicode characters
rapperskull Mar 27, 2023
37fa5e7
Fix rewrite mode skipping some files
rapperskull Mar 28, 2023
ae06b0c
Compare as unsigned in avl_compare_key
rapperskull Mar 28, 2023
53fe37a
Preserve file attributes when rewriting
rapperskull Mar 28, 2023
fe885c6
Use less memory when reading the file names
rapperskull Mar 28, 2023
2debfbb
Fix potential memory leak
rapperskull Mar 28, 2023
fd97a47
Improve speed and memory usage when rewriting or creating by using a …
rapperskull Mar 28, 2023
f03952e
Use stdbool.h, since we're compiling under C99 anyways
rapperskull Mar 29, 2023
7cae2b4
Use Windows-1252 locale if available on the system and avoid UTF-8 en…
rapperskull Mar 29, 2023
c9f5b4b
Replace nil with standard NULL, remove unused defines
rapperskull Mar 29, 2023
a56c7b2
Simplify locale selection code
rapperskull Mar 29, 2023
0e6eeaf
Add const qualifiers
rapperskull Mar 30, 2023
36a9a1f
Rewrite boyer moore implementation
rapperskull Apr 1, 2023
1bc46b4
Fix multiple ISOs extraction (fixes XboxDev/extract-xiso#85)
rapperskull Sep 4, 2023
779b0b6
Remove unnecessary seek
rapperskull Oct 3, 2023
6384074
Fix Release CI
rapperskull Oct 3, 2023
83f5901
Properly convert CP1252 filenames to uppercase
rapperskull Feb 27, 2024
4ce46e3
Fix CI build by updating FreeBSD to 13.2 and OpenBSD to 7.4
rapperskull Feb 27, 2024
bca856c
Update upload-artifact and download-artifact to v4
rapperskull Feb 27, 2024
6113b15
Allow the path to file to include symlinks
rapperskull Feb 27, 2024
2334785
Replace getopt and aspritf implementations
rapperskull Feb 28, 2024
1d92f4f
Fix CI by checking out submodules
rapperskull Feb 28, 2024
59bfde6
Replace dirent implementation with one capable of detecting symlinks
rapperskull Feb 29, 2024
9a0f38c
Include the licenses of our dependencies in the Windows release
rapperskull Feb 29, 2024
21fe68f
Make all functions static
rapperskull Mar 2, 2024
1013c56
Skip $SystemUpdate directory during tree parsing, not writing
rapperskull Mar 3, 2024
eb47daa
Remove unnecessary variable
rapperskull Mar 3, 2024
ae5f197
Update dependecy
rapperskull Mar 3, 2024
1563302
Use unsigned char for buffers
rapperskull Sep 16, 2024
1596f94
Update CI for FreeBSD 13.4, OpenBSD 7.5 and NetBSD 9.4
rapperskull Sep 16, 2024
6e3ee44
Handle XISO timestamp explicitly
rapperskull Sep 17, 2024
05582e1
Remove unnecessary parameter from extract_file
rapperskull Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow the path to file to include symlinks
Symlinks are not followed below the root, to avoid potential recursions

Windows is an exception, since we don't have an 'lstat' equivalent
  • Loading branch information
rapperskull committed Feb 28, 2024
commit 6113b15fe919ecd6fd0cd5a6d8167318f025a22b
46 changes: 28 additions & 18 deletions extract-xiso.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
#define lseek _lseeki64
#define mkdir(a, b) _mkdir(a)
#define stat _stat64
#define lstat _stat64
#define realpath(a, b) _fullpath(b, a, _MAX_PATH)

#define bswap_16(x) _byteswap_ushort(x)
Expand Down Expand Up @@ -986,35 +987,39 @@ int create_xiso( char *in_root_directory, const char *in_output_directory, dir_n
write_tree_context wt_context = { 0 };
uint32_t start_sector = 0;
int i = 0, n = 0, xiso = -1, err = 0;
char *cwd = NULL, *iso_name = NULL, *xiso_path = NULL, *iso_dir = NULL, *real_path = NULL;
char *cwd = NULL, *iso_name = NULL, *xiso_path = NULL, *iso_dir = NULL, *real_path = NULL, *in_dir_path = NULL;

s_total_bytes = s_total_files = 0;

if ( ( cwd = getcwd( NULL, 0 ) ) == NULL ) mem_err();
if ( ! err ) {
if ( ! in_root ) {
i = (int)strlen(in_root_directory) - 1;
if ( in_root_directory[i] == '/' || in_root_directory[i] == '\\' ) in_root_directory[i] = 0;
if ((iso_dir = strrchr(in_root_directory, PATH_CHAR))) iso_dir++;
else iso_dir = in_root_directory;

iso_name = in_name ? in_name : iso_dir;
} else {
if (!err) {
if (!in_root) {
if ((in_dir_path = realpath(in_root_directory, NULL)) == NULL) misc_err("unable to get absolute path of %s: %s", in_root_directory, strerror(errno));
if (!err) {
// Remember not to free in_dir_path until iso_dir is not needed anymore
if ((iso_dir = strrchr(in_dir_path, PATH_CHAR)) != NULL) iso_dir++;
else iso_dir = in_dir_path;
iso_name = in_name ? in_name : iso_dir;
}
}
else {
iso_dir = iso_name = in_root_directory;
}
}
if ( ! err ) {
if ( ! *iso_dir ) iso_dir = PATH_CHAR_STR;
if ( ! iso_name || ! *iso_name ) iso_name = "root";
else if ( iso_name[ 1 ] == ':' ) { iso_name[ 1 ] = iso_name[ 0 ]; ++iso_name; }
if (!err && (real_path = realpath(in_output_directory ? in_output_directory : ".", NULL)) == NULL) misc_err("unable to get absolute path of %s: %s", real_path, strerror(errno));
if(!err) {
if (!iso_dir || !*iso_dir) iso_dir = PATH_CHAR_STR;
if (!iso_name || !*iso_name) iso_name = "root";
else if (iso_name[1] == ':') { iso_name[1] = iso_name[0]; ++iso_name; }

if (in_output_directory == NULL) in_output_directory = ".";
if (!err && (real_path = realpath(in_output_directory, NULL)) == NULL) misc_err("unable to get absolute path of %s: %s", in_output_directory, strerror(errno));
if (!err && (asprintf(&xiso_path, "%s%c%s%s", real_path, PATH_CHAR, iso_name, in_name ? "" : ".iso")) == -1) mem_err();
if (real_path) {
free(real_path);
real_path = NULL;
}

if (!err && !in_root && chdir(in_root_directory) == -1) chdir_err(in_root_directory);
if (!err && !in_root && chdir(in_dir_path) == -1) chdir_err(in_dir_path);
}
if ( ! err ) {
exiso_log( "\n%s %s%s:\n", in_root ? "rewriting" : "creating", iso_name, in_name ? "" : ".iso" );
Expand Down Expand Up @@ -1090,7 +1095,7 @@ int create_xiso( char *in_root_directory, const char *in_output_directory, dir_n
if ( ! err && write( xiso, XISO_HEADER_DATA, XISO_HEADER_DATA_LENGTH ) != XISO_HEADER_DATA_LENGTH ) write_err();

if ( ! err && ! in_root ) {
if ( chdir( ".." ) == -1 ) chdir_err( ".." );
if (chdir("..") == -1) chdir_err("..");
}
if (!err && (root.filename = strdup(iso_dir)) == NULL) mem_err();
if (!err) {
Expand Down Expand Up @@ -1138,6 +1143,11 @@ int create_xiso( char *in_root_directory, const char *in_output_directory, dir_n
if (root.filename) free(root.filename);
if (root.filename_cp1252) free(root.filename_cp1252);

if (in_dir_path) {
free(in_dir_path);
in_dir_path = NULL;
}

if ( cwd ) {
if ( chdir( cwd ) == -1 ) chdir_err( cwd );
free( cwd );
Expand Down Expand Up @@ -2032,7 +2042,7 @@ int generate_avl_tree_local( dir_node_avl **out_root, int *io_n ) {
avl->filename = NULL;
} else if ((avl->filename_cp1252 = getCP1252String(p->d_name)) == NULL) mem_err();
}
if ( ! err && stat( p->d_name, &sb ) == -1 ) read_err();
if ( ! err && lstat( p->d_name, &sb ) == -1 ) read_err();
if ( ! err ) {
if ( S_ISDIR( sb.st_mode ) ) {
empty_dir = false;
Expand Down