Files
flutter_server_box/lib/data/model/sftp/absolute_path.dart
Junyuan Feng f07d33a1d6 SFTP init.
2022-02-18 13:32:50 +08:00

30 lines
536 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) {
return false;
}
path = _prePath!;
return true;
}
}