diff --git a/CHANGELOG.md b/CHANGELOG.md index a533b86..d6d2cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,13 @@ ### Changed - Requires PHP `8.5` +- Requires `innmind/url:~5.4` - Requires `innmind/black-box:~7.0` +### Fixed + +- All paths are declared as file paths to allow otherwise restricted `?` and `#` + ## 4.1.1 - 2026-04-09 ### Fixed diff --git a/README.md b/README.md index 1c8e782..c116cec 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ use Innmind\Immutable\Str; $chunks = IO::fromAmbienAuthority() ->files() - ->read(Path::of('/some/file.ext')) + ->read(Path::file('/some/file.ext')) ->toEncoding(Str\Encoding::ascii) ->chunks(8192); // max length of each chunk ``` diff --git a/composer.json b/composer.json index 8087638..10e876f 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": "~8.5", "innmind/immutable": "~6.0", "innmind/mutable": "~1.0", - "innmind/url": "~5.0", + "innmind/url": "~5.4", "innmind/time": "~1.0", "innmind/ip": "~4.0", "innmind/validation": "~3.0" diff --git a/documentation/files/read.md b/documentation/files/read.md index 157630d..8d39eb6 100644 --- a/documentation/files/read.md +++ b/documentation/files/read.md @@ -9,7 +9,7 @@ use Innmind\Url\Path; $chunks = IO::fromAmbientAuthority() ->files() - ->read(Path::of('/path/to/file.ext')) + ->read(Path::file('/path/to/file.ext')) ->chunks(8192); ``` @@ -23,7 +23,7 @@ use Innmind\Url\Path; $chunks = IO::fromAmbientAuthority() ->files() - ->read(Path::of('/path/to/file.ext')) + ->read(Path::file('/path/to/file.ext')) ->lines(); ``` @@ -40,7 +40,7 @@ use Innmind\Immutable\Str; $chunks = IO::fromAmbientAuthority() ->files() - ->read(Path::of('/path/to/file.ext')) + ->read(Path::file('/path/to/file.ext')) ->toEncoding(Str\Encoding::ascii) ->lines(); ``` diff --git a/documentation/files/write.md b/documentation/files/write.md index 19de95b..6ae1664 100644 --- a/documentation/files/write.md +++ b/documentation/files/write.md @@ -11,7 +11,7 @@ use Innmind\Immutable\{ $successful = IO::fromAmbientAuthority() ->files() - ->write(Path::of('/path/to/file.ext')) + ->write(Path::file('/path/to/file.ext')) ->sink(Sequence::of( Str::of('chunk 1'), Str::of("new line \n"), diff --git a/documentation/sockets.md b/documentation/sockets.md index a6a243a..fb3e29b 100644 --- a/documentation/sockets.md +++ b/documentation/sockets.md @@ -43,7 +43,7 @@ $server = IO::fromAmbientAuthority() ->sockets() ->servers() ->unix(Address::of( - Path::of('/path/to/socket'), + Path::file('/path/to/socket'), )) ->unwrap(); ``` @@ -63,7 +63,7 @@ $server = IO::fromAmbientAuthority() ->sockets() ->servers() ->takeOver(Address::of( - Path::of('/path/to/socket'), + Path::file('/path/to/socket'), )) ->unwrap(); ``` @@ -144,7 +144,7 @@ $client = IO::fromAmbientAuthority() ->sockets() ->clients() ->unix(Address::of( - Path::of('/path/to/socket'), + Path::file('/path/to/socket'), )) ->unwrap(); ``` diff --git a/documentation/use-cases/files/chunks.md b/documentation/use-cases/files/chunks.md index fb0a69f..0ad6857 100644 --- a/documentation/use-cases/files/chunks.md +++ b/documentation/use-cases/files/chunks.md @@ -12,7 +12,7 @@ use Innmind\Immutable\Str; $chunks = IO::fromAmbienAuthority() ->files() - ->read(Path::of('/some/file.ext')) + ->read(Path::file('/some/file.ext')) ->toEncoding(Str\Encoding::ascii) ->chunks(8192); // max length of each chunk ``` diff --git a/documentation/use-cases/files/lines.md b/documentation/use-cases/files/lines.md index 18669ba..b9e1fa9 100644 --- a/documentation/use-cases/files/lines.md +++ b/documentation/use-cases/files/lines.md @@ -12,7 +12,7 @@ use Innmind\Immutable\Str; $lines = IO::fromAmbienAuthority() ->files() - ->read(Path::of('/some/file.ext')) + ->read(Path::file('/some/file.ext')) ->toEncoding(Str\Encoding::ascii) ->lines(); ``` diff --git a/proofs/files.php b/proofs/files.php index ee63b36..0abec44 100644 --- a/proofs/files.php +++ b/proofs/files.php @@ -6,6 +6,7 @@ Files\Read, Files\Temporary, Files\Temporary\Pull, + Files\Directory, }; use Innmind\Url\Path; use Innmind\Immutable\{ @@ -447,4 +448,22 @@ static function($assert) { ); }, ); + + yield $prove->test( + 'IO::files() can read a directory containing a #', + static function($assert) { + $tmp = \sys_get_temp_dir(); + @\rmdir($tmp.'/innmind/#/'); + @\mkdir($tmp.'/innmind/#/', recursive: true); + + $assert + ->object( + IO::fromAmbientAuthority() + ->files() + ->access(Path::file($tmp.'/innmind/#')) + ->unwrap(), + ) + ->instance(Directory::class); + }, + ); }; diff --git a/src/Files/Directory.php b/src/Files/Directory.php index b675b44..d370938 100644 --- a/src/Files/Directory.php +++ b/src/Files/Directory.php @@ -28,7 +28,7 @@ public static function of( Path $path, ): self { if (!$path->directory()) { - $path = Path::of($path->toString().'/'); + $path = Path::file($path->toString().'/'); } return new self($capabilities, $path); diff --git a/src/Internal/Capabilities/Files/AmbientAuthority.php b/src/Internal/Capabilities/Files/AmbientAuthority.php index 172bb8a..3208845 100644 --- a/src/Internal/Capabilities/Files/AmbientAuthority.php +++ b/src/Internal/Capabilities/Files/AmbientAuthority.php @@ -234,7 +234,7 @@ private function touch(Path $path): Attempt private function rmdir(string $path): Attempt { return $this - ->list(Path::of($path)) + ->list(Path::file($path)) ->map(static fn($name) => \sprintf( '%s%s%s', $path, @@ -244,7 +244,7 @@ private function rmdir(string $path): Attempt default => '', }, )) - ->map(Path::of(...)) + ->map(Path::file(...)) ->sink(SideEffect::identity) ->attempt(fn($_, $file) => $this->remove($file)) ->map(static fn() => @\rmdir($path)) diff --git a/src/Sockets/Unix/Address.php b/src/Sockets/Unix/Address.php index 1d9e69b..016e34f 100644 --- a/src/Sockets/Unix/Address.php +++ b/src/Sockets/Unix/Address.php @@ -28,7 +28,7 @@ public static function of(Path $path): self #[\NoDiscard] public function asPath(): Path { - return Path::of($this->toString()); + return Path::file($this->toString()); } #[\NoDiscard]