mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
SFTP init.
This commit is contained in:
29
lib/data/model/sftp/absolute_path.dart
Normal file
29
lib/data/model/sftp/absolute_path.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user