Implemented option -mkdir

This commit is contained in:
Thomas Schmitt 2007-10-28 16:54:29 +00:00
parent 99cb813d42
commit 7511f4e4bc
5 changed files with 54 additions and 13 deletions

View File

@ -297,7 +297,7 @@ Alter the date entries of a file in the ISO image. type is
one of "a", "m", "b" for access time, modification time, one of "a", "m", "b" for access time, modification time,
both times. both times.
.TP .TP
> \fB\-mkdir\fR iso_rr_path [...] \fB\-mkdir\fR iso_rr_path [...]
Create empty directories if they do not exist yet. Create empty directories if they do not exist yet.
Existence as directory generates a WARNING event, existence as Existence as directory generates a WARNING event, existence as
other file cause a SORRY event. other file cause a SORRY event.

View File

@ -4100,17 +4100,21 @@ int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag)
int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv, int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag) int *idx, int flag)
{ {
int i, end_idx; int i, end_idx, ret, was_failure= 0;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0);
fprintf(stderr, ">>> LIBISOFS : -mkdiri "); for(i= *idx; i<end_idx; i++) {
for(i= *idx; i<end_idx; i++) ret= Xorriso_mkdir(xorriso, argv[i], 0);
fprintf(stderr, "%s ", argv[i]); if(ret<0)
fprintf(stderr, "\n"); {ret= 0; goto ex;}
if(ret==0)
was_failure= 1;
}
ret= 1;
ex:;
(*idx)= end_idx; (*idx)= end_idx;
return(1); return(ret>0 && !was_failure);
} }

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.10.28.125501" #define Xorriso_timestamP "2007.10.28.165516"

View File

@ -1394,8 +1394,7 @@ ex:;
} }
int Xorriso_rename(struct XorrisO *xorriso, int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
char origin[], char dest[], int flag)
{ {
int ret, ol, dest_ret; int ret, ol, dest_ret;
char sfe[4*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; char sfe[4*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt;
@ -1508,3 +1507,37 @@ int Xorriso_rename(struct XorrisO *xorriso,
} }
/* @param flag bit0= do not produce info message on success
@return 1=success,
0=was already directory, -1=was other type, -2=other error
*/
int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag)
{
int ret;
char eff_path[SfileadrL], sfe[4*SfileadrL];
ret= Xorriso_normalize_img_path(xorriso, path, eff_path, 1);
if(ret<0)
return(-2);
if(ret>0) {
sprintf(xorriso->info_text,"-mkdir: Address already existing %s",
Text_shellsafe(eff_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
(ret==2 ? "WARNING" : "SORRY"), 0);
return(-1+(ret==2));
}
ret= Xorriso_normalize_img_path(xorriso, path, eff_path, 2);
if(ret<0)
return(-2);
ret= Xorriso_graft_in(xorriso, NULL, eff_path, 1);
if(ret<=0)
return(-2);
if(!(flag&1)) {
sprintf(xorriso->info_text, "Created directory in ISO image: %s\n",
Text_shellsafe(eff_path,sfe,0));
Xorriso_info(xorriso, 0);
}
return(1);
}

View File

@ -69,8 +69,12 @@ int Xorriso_ls(struct XorrisO *xorriso, int flag);
int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *img_path, int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *img_path,
char eff_path[], int flag); char eff_path[], int flag);
int Xorriso_rename(struct XorrisO *xorriso, int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest,int flag);
char origin[], char dest[], int flag);
/* @param flag bit0= do not produce info message on success
@return 1=success, 0=was already directory, -1=was other type, -2=bad path
*/
int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag);
#endif /* Xorrisoburn_includeD */ #endif /* Xorrisoburn_includeD */