Skip to content

Commit d1f1f3a

Browse files
committed
LocalFilesystem::resolvePath()
1 parent 2ea6616 commit d1f1f3a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

components/Filesystem/LocalFilesystem.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function copy_file( $from_path, $to_path, $options ) {
109109
}
110110

111111
protected function mkdir_single( $path, $options = array() ) {
112+
$path = $this->resolve_path( $path );
112113
if ( $this->exists( $path ) ) {
113114
throw new FilesystemException(
114115
sprintf( 'Path already exists: %s', $path )
@@ -162,4 +163,19 @@ public function open_write_stream( $path ): ByteWriteStream {
162163
public function open_read_stream( $path ): ByteReadStream {
163164
return FileReadStream::from_path( $path );
164165
}
166+
167+
/**
168+
* Turns a linux path into an OS-specific path.
169+
*
170+
* This is necessary because Filesystem-related classes use
171+
* forward slashes to separate paths. They must. LocalFilesystem
172+
* is just one of the available Filesystem implementations.
173+
*
174+
* Therefore, the problem of converting forward slashes to
175+
* OS-specific path separators is specific to the LocalFilesystem
176+
* class
177+
*/
178+
private function resolve_path( $path ) {
179+
return str_replace( '/', DIRECTORY_SEPARATOR, $path );
180+
}
165181
}

0 commit comments

Comments
 (0)