Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/gilnobrega/universal_disk_space
- Owner: gilnobrega
- License: mit
- Created: 2021-04-18T17:51:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-02T17:45:20.000Z (almost 2 years ago)
- Last Synced: 2023-08-20T23:27:39.015Z (over 1 year ago)
- Language: Dart
- Size: 72.3 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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);
}
```