mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
New feat
- SFTP download - open downloaded files in other apps
This commit is contained in:
38
lib/data/model/app/path_with_prefix.dart
Normal file
38
lib/data/model/app/path_with_prefix.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
class PathWithPrefix {
|
||||
late String _prefixPath;
|
||||
String _path = '/';
|
||||
String? _prePath;
|
||||
String get path => _prefixPath + _path;
|
||||
|
||||
PathWithPrefix(String prefixPath) {
|
||||
if (prefixPath.endsWith('/')) {
|
||||
_prefixPath = prefixPath.substring(0, prefixPath.length - 1);
|
||||
} else {
|
||||
_prefixPath = prefixPath;
|
||||
}
|
||||
}
|
||||
|
||||
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 || _path == _prePath) {
|
||||
return false;
|
||||
}
|
||||
_path = _prePath!;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user