From b06cc331d68f8ae566ab77cfe2660470d7759ec1 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 10 Feb 2008 13:59:11 +0000 Subject: [PATCH] Better handling of not-yet-existing -cd --- xorriso/xorriso.c | 13 +++++++++++++ xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.c | 13 +++++++++++++ xorriso/xorrisoburn.h | 3 +++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/xorriso/xorriso.c b/xorriso/xorriso.c index b4e5a69d..04c4aa1c 100644 --- a/xorriso/xorriso.c +++ b/xorriso/xorriso.c @@ -7349,6 +7349,7 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, int ret, end_idx, filec= 0, nump, i; char **filev= NULL, **patterns= NULL; off_t mem= 0; + struct stat stbuf; end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); if(xorriso->do_iso_rr_pattern==0) @@ -7358,6 +7359,18 @@ int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, if((flag&2) && nump>0 ) { ; } else if(nump <= 0) { + if(Xorriso_iso_lstat(xorriso, xorriso->wdi, &stbuf, 0)==-1) { + sprintf(xorriso->info_text, + "Current -cd path does not yet exist in the ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + if(!S_ISDIR(stbuf.st_mode)) { + sprintf(xorriso->info_text, + "Current -cd meanwhile points to a non-directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } patterns= calloc(1, sizeof(char *)); if(patterns == NULL) { no_memory:; diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 0d9d7bde..861255f7 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.02.10.130852" +#define Xorriso_timestamP "2008.02.10.135822" diff --git a/xorriso/xorrisoburn.c b/xorriso/xorrisoburn.c index 43fc9159..6114055c 100644 --- a/xorriso/xorrisoburn.c +++ b/xorriso/xorrisoburn.c @@ -2566,6 +2566,19 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, } +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_fake_stbuf(xorriso, path, stbuf, &node, 0); + if(ret>0) + return(0); + return(-1); +} + + int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node, int *filec, char ***filev, off_t boss_mem, int flag) { diff --git a/xorriso/xorrisoburn.h b/xorriso/xorrisoburn.h index 36d6e21c..413a26a3 100644 --- a/xorriso/xorrisoburn.h +++ b/xorriso/xorrisoburn.h @@ -145,6 +145,9 @@ int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag); int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag); +/* @return 0= stbuf content is valid , -1 = path not found */ +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag); #endif /* Xorrisoburn_includeD */