os 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new53

Overview #

This package provides access to various low-level APIs of operating systems. The package binds with libc (Linux, Mac OS X) and kernel32.dll (Windows) using dart:ffi.

The project is licensed under the Apache License 2.0.

Status #

Passes tests in:

  • Darwin (OS X)

Fails tests in:

  • Linux
  • Windows

Issues? #

APIs #

os.file_system #

Library 'package:os/file_system.dart' provides access to various functions not supported by 'dart:io'.

Examples:

chmodSync(Directory("some/path"), 0x1FF); // Octal: 777

Named pipes (also known as "POSIX pipes") are sometimes used for inter-process communication in operating systems such as Linux and Mac OS X.

void main() async {
  // Create the pipe
  final namedPipe = NamedPipe("some/path");
  namedPipe.createSync();

  // Write something
  final writer = namedPipe.openWrite()
  writer.add([1,2,3])
  await writer.close();

  // Delete the pipe
  namedPipe.deleteSync();
}

os.virtual_memory #

Library 'package:os/memory.dart' enables you to control virtual memory tables.

void main() async {
  // Allocate memory
  final memory = VirtualMemory.allocate(1024);

  // Set protection bits
  memory.setProtection(VirtualMemory.protectionReadWrite);

  // Write to the memory
  memory.asUint8List[23] = 29;

  // Free the memory
  memory.free();
}

Changelog #

0.1.1 #

  • Small fixes suggested by the package analyzer.

0.1.0 #

  • Initial release.

example/example.dart

import 'package:os/virtual_memory.dart';

void main() {
  // Allocate virtual memory
  final memory = VirtualMemory.allocate(1024);
  memory.asUint8List[0] = 42;

  // Make the memory read-only
  memory.setProtection(VirtualMemory.protectionWrite);

  // Any mutation will result in a crash now
  memory.asUint8List[0] = 99;
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  os: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:os/file_system.dart';
import 'package:os/loading.dart';
import 'package:os/virtual_memory.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
5
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Oct 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Platform components identified in package: io.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0-dev.2.1 <3.0.0
ffi ^0.1.1 0.1.2 0.1.3-dev.1
meta ^1.1.0 1.1.7
Dev dependencies
pedantic ^1.8.0
test ^1.6.0