chmod function
Change the permission of filename
.
Pass in the permissions
as an octal string e.g. 777
to change the file permissions.
If the call fails a PosixException is thrown with the value of errno.
Implementation
void chmod(
String filename,
String permissions,
) {
final _permissions = int.parse(permissions, radix: 8);
final cFilename = filename.toNativeUtf8();
clearErrno();
_chmod ??= Libc().dylib.lookupFunction<
ffi.Int32 Function(ffi.Pointer<Utf8>, ffi.Uint32), _dart_chmod>('chmod');
final results = _chmod!(
cFilename,
_permissions,
);
malloc.free(cFilename);
if (results != 0) {
final error = errno();
throw PosixException('chown failed error: ${strerror(error)}', error);
}
}