Commit 9e32be4a authored by Claes Sjofors's avatar Claes Sjofors

Build directory, directory created if it doesn't exist

parent 49e06cc1
......@@ -1687,7 +1687,9 @@ void wb_build::directories( char *dir, bld_ePass pass)
// Check if file should be updated
int update = 0;
pwr_tFileName source, target;
pwr_tFileName target_dir;
pwr_tTime source_time, target_time;
char *s;
strncpy( source, found_file, sizeof(source));
strncpy( target, line_item[3], sizeof(target));
......@@ -1714,6 +1716,18 @@ void wb_build::directories( char *dir, bld_ePass pass)
if ( !opt.force && !update)
continue;
if ( EVEN(sts)) {
// Check that directory exist, create if it doesn't
strcpy( target_dir, target);
if ( (s = strrchr( target_dir, '/'))) {
*s = 0;
sts = dcli_file_time( target_dir, &target_time);
if ( EVEN(sts)) {
sprintf( cmd, "mkdir -p %s", target_dir);
system( cmd);
}
}
}
sprintf( cmd, "cp %s %s", source, target);
system( cmd);
sprintf( cmd, "Build: copy %s %s -> %s", line_item[1], source, target);
......
......@@ -1194,6 +1194,25 @@ pwr_tStatus WbExpWNav::exp()
sprintf( cmd, "cp %s %s", cp->source, cp->target);
printf( "%s\n", cmd);
sts = system( cmd);
if ( sts != 0) {
// Check that directory exist, create if it doesn't
pwr_tFileName target_dir;
pwr_tTime target_time;
char *s;
strcpy( target_dir, cp->target);
if ( (s = strrchr( target_dir, '/'))) {
*s = 0;
sts = dcli_file_time( target_dir, &target_time);
if ( EVEN(sts)) {
sprintf( cmd, "mkdir -p %s", target_dir);
system( cmd);
sprintf( cmd, "cp %s %s", cp->source, cp->target);
printf( "%s\n", cmd);
sts = system( cmd);
}
}
if ( sts != 0) {
char msg[250];
snprintf( msg, sizeof(msg), "Build error %d, %s", WEXITSTATUS(sts), cmd);
......@@ -1201,6 +1220,7 @@ pwr_tStatus WbExpWNav::exp()
}
}
}
}
for ( ExpWDir *dp = dirlist; dp; dp = dp->next) {
if ( !dp->update)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment