diff --git a/src/Driver/EioDriver.php b/src/Driver/EioDriver.php index 2c2c250..69b2ca2 100644 --- a/src/Driver/EioDriver.php +++ b/src/Driver/EioDriver.php @@ -146,6 +146,7 @@ public function createDirectoryRecursively(string $path, int $mode = 0777): Prom $priority = \EIO_PRI_DEFAULT; $path = \str_replace("/", DIRECTORY_SEPARATOR, $path); + $path = \rtrim($path, DIRECTORY_SEPARATOR); $arrayPath = \explode(DIRECTORY_SEPARATOR, $path); $tmpPath = ""; diff --git a/src/Driver/UvDriver.php b/src/Driver/UvDriver.php index 3a02e17..989aec4 100644 --- a/src/Driver/UvDriver.php +++ b/src/Driver/UvDriver.php @@ -205,6 +205,7 @@ public function createDirectoryRecursively(string $path, int $mode = 0777): Prom $this->poll->listen($deferred->promise()); $path = \str_replace("/", DIRECTORY_SEPARATOR, $path); + $path = \rtrim($path, DIRECTORY_SEPARATOR); $arrayPath = \explode(DIRECTORY_SEPARATOR, $path); $tmpPath = ""; diff --git a/test/DriverTest.php b/test/DriverTest.php index 298fd08..03de5e6 100644 --- a/test/DriverTest.php +++ b/test/DriverTest.php @@ -344,6 +344,16 @@ public function testCreateAndDeleteDirectory(): \Generator $this->assertSame('0744', $this->getPermissionsFromStatus($stat)); } + public function testCreateDirectoryRecursivelySlashEnd(): \Generator + { + $fixtureDir = Fixture::path(); + + $dir = "{$fixtureDir}/newdir/with/recursive/creation/321/"; + + $this->assertNull(yield $this->driver->createDirectoryRecursively($dir, 0764)); + $this->assertTrue(yield $this->driver->exists($dir)); + } + public function testCreateDirectoryFailsOnNonexistentPath(): \Generator { $fixtureDir = Fixture::path();