Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gilnobrega/universal_disk_space

A dart package which shows total and available space of disks in Linux and Windows
https://github.com/gilnobrega/universal_disk_space

Last synced: about 2 months ago
JSON representation

A dart package which shows total and available space of disks in Linux and Windows

Awesome Lists containing this project

README

        

# Universal Disk Space
A Dart package which parses total and available disk spaces on Windows and UNIX-based systems (including Linux and macOS).

## Usage
Add ``universal_disk_space`` as a dependency to your project's ``pubspec.yaml`` file.

## Example

``` dart
import 'dart:io';

import 'package:universal_disk_space/universal_disk_space.dart';

Future main() async {
// Initializes the DiskSpace class.
final diskSpace = DiskSpace();

// Scan for disks in the system.
await diskSpace.scan();

// A list of disks in the system.
var disks = diskSpace.disks;

// Prints the device path, mount path, and total size of each disk in system.
for (final disk in disks) {
print(disk.devicePath); // e.g.: 'C:\' in Windows or '/dev/sdc' in Linux
print(disk
.mountPath); // e.g.: 'C:\' or '\\nasdrive' in Windows or '/' in Linux
print(disk.totalSize.toString()); // in bytes
print(disk.usedSpace.toString()); // in bytes
print(disk.availableSpace.toString()); // in bytes
print('');
}

/// Searches for the disk that '/home' belongs to.
/// Any FileSystemEntity can be used.
var homeDisk = diskSpace.getDisk(Directory('/home'));
print(homeDisk);
}
```