diff --git a/configure.php b/configure.php index c7873d339..18e680d3f 100755 --- a/configure.php +++ b/configure.php @@ -110,7 +110,7 @@ function realpain( string $path , bool $touch = false , bool $mkdir = false ) : $res = realpath( $path ); if ( is_string( $res ) ) - $path = $res; + $path = str_replace( "\\" , '/' , $res ); return $path; } diff --git a/scripts/file-entities.php b/scripts/file-entities.php index 8b0d697a3..ac77f442d 100644 --- a/scripts/file-entities.php +++ b/scripts/file-entities.php @@ -310,7 +310,7 @@ function writeEntity( $file , Entity $ent ) fwrite( $file , $line ); } -function realpain( string $path , bool $touch = false ) : string +function realpain( string $path , bool $touch = false , bool $mkdir = false ) : string { // pain is real @@ -318,12 +318,17 @@ function realpain( string $path , bool $touch = false ) : string // care for Windows builds (foward slashes everywhere) // avoid `cd` and chdir() like the plague + $path = str_replace( "\\" , '/' , $path ); + + if ( $mkdir && ! file_exists( $path ) ) + mkdir( $path , recursive: true ); + if ( $touch && ! file_exists( $path ) ) touch( $path ); $res = realpath( $path ); - if ($res !== false) - $path = $res; + if ( is_string( $res ) ) + $path = str_replace( "\\" , '/' , $res ); return $path; }