mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
fix recursiveCopy to preserve executable bit (#39505)
This commit is contained in:
parent
a2957c571e
commit
8ec2c5828d
@ -124,6 +124,11 @@ void recursiveCopy(Directory source, Directory target) {
|
||||
else if (entity is File) {
|
||||
final File dest = File(path.join(target.path, name));
|
||||
dest.writeAsBytesSync(entity.readAsBytesSync());
|
||||
// Preserve executable bit
|
||||
final String modes = entity.statSync().modeString();
|
||||
if (modes != null && modes.contains('x')) {
|
||||
makeExecutable(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,6 +139,27 @@ FileSystemEntity move(FileSystemEntity whatToMove,
|
||||
.renameSync(path.join(to.path, name ?? path.basename(whatToMove.path)));
|
||||
}
|
||||
|
||||
/// Equivalent of `chmod a+x file`
|
||||
void makeExecutable(File file) {
|
||||
// Windows files do not have an executable bit
|
||||
if (Platform.isWindows) {
|
||||
return;
|
||||
}
|
||||
final ProcessResult result = _processManager.runSync(<String>[
|
||||
'chmod',
|
||||
'a+x',
|
||||
file.path,
|
||||
]);
|
||||
|
||||
if (result.exitCode != 0) {
|
||||
throw FileSystemException(
|
||||
'Error making ${file.path} executable.\n'
|
||||
'${result.stderr}',
|
||||
file.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Equivalent of `mkdir directory`.
|
||||
void mkdir(Directory directory) {
|
||||
directory.createSync();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user