From 433200e63b119bacd8ed595a4ecd24118f66ec03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20L=20F=20S=20Bacci?= Date: Wed, 22 Jan 2025 15:10:49 -0300 Subject: [PATCH] Fix Windows build (foward slashes everywhere) --- configure.php | 2 +- scripts/file-entities.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) 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; }