Skip to content

Commit b12b9bb

Browse files
alfsbAndré L F S Bacci
andauthored
Fix Windows build (foward slashes everywhere) (#214)
Co-authored-by: André L F S Bacci <[email protected]>
1 parent e620347 commit b12b9bb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

configure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function realpain( string $path , bool $touch = false , bool $mkdir = false ) :
110110

111111
$res = realpath( $path );
112112
if ( is_string( $res ) )
113-
$path = $res;
113+
$path = str_replace( "\\" , '/' , $res );
114114

115115
return $path;
116116
}

scripts/file-entities.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,20 +310,25 @@ function writeEntity( $file , Entity $ent )
310310
fwrite( $file , $line );
311311
}
312312

313-
function realpain( string $path , bool $touch = false ) : string
313+
function realpain( string $path , bool $touch = false , bool $mkdir = false ) : string
314314
{
315315
// pain is real
316316

317317
// care for external XML tools (realpath() everywhere)
318318
// care for Windows builds (foward slashes everywhere)
319319
// avoid `cd` and chdir() like the plague
320320

321+
$path = str_replace( "\\" , '/' , $path );
322+
323+
if ( $mkdir && ! file_exists( $path ) )
324+
mkdir( $path , recursive: true );
325+
321326
if ( $touch && ! file_exists( $path ) )
322327
touch( $path );
323328

324329
$res = realpath( $path );
325-
if ($res !== false)
326-
$path = $res;
330+
if ( is_string( $res ) )
331+
$path = str_replace( "\\" , '/' , $res );
327332

328333
return $path;
329334
}

0 commit comments

Comments
 (0)