mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
30 lines
556 B
Dart
30 lines
556 B
Dart
class AbsolutePath {
|
|
String path;
|
|
String? _prePath;
|
|
AbsolutePath(this.path);
|
|
|
|
void update(String newPath) {
|
|
_prePath = path;
|
|
if (newPath == '..') {
|
|
path = path.substring(0, path.lastIndexOf('/'));
|
|
if (path == '') {
|
|
path = '/';
|
|
}
|
|
return;
|
|
}
|
|
if (newPath == '/') {
|
|
path = '/';
|
|
return;
|
|
}
|
|
path = path + (path.endsWith('/') ? '' : '/') + newPath;
|
|
}
|
|
|
|
bool undo() {
|
|
if (_prePath == null || _prePath == path) {
|
|
return false;
|
|
}
|
|
path = _prePath!;
|
|
return true;
|
|
}
|
|
}
|