1
0
mirror of https://github.com/danog/file.git synced 2024-11-26 11:54:54 +01:00

Fixes wrong mkdir default mode

This commit is contained in:
Manuele Menozzi 2018-03-15 18:35:10 +01:00
parent 36bb70a95b
commit ed5495f084
2 changed files with 13 additions and 3 deletions

View File

@ -242,7 +242,7 @@ function unlink(string $path): Promise {
* @param bool $recursive
* @return \Amp\Promise<null>
*/
function mkdir(string $path, int $mode = 0644, bool $recursive = false): Promise {
function mkdir(string $path, int $mode = 0777, bool $recursive = false): Promise {
return filesystem()->mkdir($path, $mode, $recursive);
}

View File

@ -224,9 +224,11 @@ abstract class DriverTest extends TestCase {
$dir = "{$fixtureDir}/newdir";
\umask(0022);
yield File\mkdir($dir);
$stat = yield File\stat($dir);
$this->assertSame(0644, $stat["mode"] & 0777);
$this->assertSame('0755', $this->getPermissionsFromStat($stat));
yield File\rmdir($dir);
$this->assertNull(yield File\stat($dir));
@ -235,7 +237,7 @@ abstract class DriverTest extends TestCase {
yield File\mkdir($dir, 0764, true);
$stat = yield File\stat($dir);
$this->assertSame(0764 & (~\umask()), $stat["mode"] & 0777);
$this->assertSame('0744', $this->getPermissionsFromStat($stat));
});
}
@ -325,4 +327,12 @@ abstract class DriverTest extends TestCase {
$this->assertTrue($newStat["mtime"] > $oldStat["mtime"]);
});
}
/**
* @param array $stat
* @return string
*/
private function getPermissionsFromStat(array $stat): string {
return \substr(\decoct($stat["mode"]), 1);
}
}