opt.: sftp home & back (#533)

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-14 19:01:44 +08:00
committed by GitHub
parent 41e3fcb23a
commit 267b0b0a69
59 changed files with 466 additions and 477 deletions

View File

@@ -2,12 +2,14 @@ import 'package:fl_lib/fl_lib.dart';
class AbsolutePath {
String _path;
final _prePath = <String>[];
AbsolutePath(this._path);
String get path => _path;
final List<String> _prePath;
AbsolutePath(this._path) : _prePath = ['/'];
void update(String newPath) {
/// Update path, not set path
set path(String newPath) {
_prePath.add(_path);
if (newPath == '..') {
_path = _path.substring(0, _path.lastIndexOf('/'));
@@ -16,10 +18,6 @@ class AbsolutePath {
}
return;
}
if (newPath == '/') {
_path = '/';
return;
}
if (newPath.startsWith('/')) {
_path = newPath;
return;

View File

@@ -2,9 +2,11 @@ import 'package:dartssh2/dartssh2.dart';
import 'package:server_box/data/model/sftp/absolute_path.dart';
class SftpBrowserStatus {
List<SftpName>? files;
AbsolutePath? path;
final List<SftpName> files = [];
final AbsolutePath path = AbsolutePath('/');
SftpClient? client;
SftpBrowserStatus();
SftpBrowserStatus(SSHClient client) {
client.sftp().then((value) => this.client = value);
}
}