mirror of
https://github.com/danog/file.git
synced 2024-11-30 04:19:39 +01:00
Fixes wrong mkdir default mode
This commit is contained in:
parent
36bb70a95b
commit
ed5495f084
@ -242,7 +242,7 @@ function unlink(string $path): Promise {
|
|||||||
* @param bool $recursive
|
* @param bool $recursive
|
||||||
* @return \Amp\Promise<null>
|
* @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);
|
return filesystem()->mkdir($path, $mode, $recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,9 +224,11 @@ abstract class DriverTest extends TestCase {
|
|||||||
|
|
||||||
$dir = "{$fixtureDir}/newdir";
|
$dir = "{$fixtureDir}/newdir";
|
||||||
|
|
||||||
|
\umask(0022);
|
||||||
|
|
||||||
yield File\mkdir($dir);
|
yield File\mkdir($dir);
|
||||||
$stat = yield File\stat($dir);
|
$stat = yield File\stat($dir);
|
||||||
$this->assertSame(0644, $stat["mode"] & 0777);
|
$this->assertSame('0755', $this->getPermissionsFromStat($stat));
|
||||||
yield File\rmdir($dir);
|
yield File\rmdir($dir);
|
||||||
$this->assertNull(yield File\stat($dir));
|
$this->assertNull(yield File\stat($dir));
|
||||||
|
|
||||||
@ -235,7 +237,7 @@ abstract class DriverTest extends TestCase {
|
|||||||
|
|
||||||
yield File\mkdir($dir, 0764, true);
|
yield File\mkdir($dir, 0764, true);
|
||||||
$stat = yield File\stat($dir);
|
$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"]);
|
$this->assertTrue($newStat["mtime"] > $oldStat["mtime"]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $stat
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function getPermissionsFromStat(array $stat): string {
|
||||||
|
return \substr(\decoct($stat["mode"]), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user