56 lines
1.1 KiB
Dart
56 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:dart_framework/platform/process.dart';
|
|
|
|
class RegistPath {
|
|
static RegistPath? _instance;
|
|
// ignore: library_private_types_in_public_api
|
|
static RegistPath? get OS {
|
|
if (_instance == null) {
|
|
if (Platform.isMacOS) {
|
|
_instance = _RegistPathOSX();
|
|
} else if (Platform.isLinux) {
|
|
_instance = _RegistPathLinux();
|
|
} else {
|
|
_instance = _RegistPathWindows();
|
|
}
|
|
}
|
|
return _instance;
|
|
}
|
|
|
|
void add(String path) {
|
|
_instance?.add(path);
|
|
}
|
|
|
|
void remove(String path) {
|
|
_instance?.remove(path);
|
|
}
|
|
}
|
|
|
|
class _RegistPathOSX extends RegistPath {
|
|
@override
|
|
void add(String path) {}
|
|
|
|
@override
|
|
void remove(String path) {}
|
|
}
|
|
|
|
class _RegistPathLinux extends RegistPath {
|
|
@override
|
|
void add(String path) {}
|
|
|
|
@override
|
|
void remove(String path) {}
|
|
}
|
|
|
|
class _RegistPathWindows extends RegistPath {
|
|
@override
|
|
void add(String path) {
|
|
ProcessExecutor.run(StringBuffer('setx path "%path%;$path"'));
|
|
}
|
|
|
|
@override
|
|
void remove(String path) {
|
|
ProcessExecutor.run(StringBuffer('setx path "%path:$path=%"'));
|
|
}
|
|
}
|