mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: rename file
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
|
||||
class AbsolutePath {
|
||||
String _path;
|
||||
final _prePath = <String>[];
|
||||
|
||||
AbsolutePath(this._path);
|
||||
|
||||
String get path => _path;
|
||||
|
||||
/// Update path, not set path
|
||||
set path(String newPath) {
|
||||
_prePath.add(_path);
|
||||
if (newPath == '..') {
|
||||
_path = _path.substring(0, _path.lastIndexOf('/'));
|
||||
if (_path == '') {
|
||||
_path = '/';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (newPath.startsWith('/')) {
|
||||
_path = newPath;
|
||||
return;
|
||||
}
|
||||
_path = _path.joinPath(newPath, seperator: '/');
|
||||
}
|
||||
|
||||
bool undo() {
|
||||
if (_prePath.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
_path = _prePath.removeLast();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,49 @@
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:server_box/data/model/sftp/absolute_path.dart';
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
|
||||
/// Remote server only can be linux-like system, so use '/' as seperator
|
||||
const _sep = '/';
|
||||
|
||||
class SftpBrowserStatus {
|
||||
final List<SftpName> files = [];
|
||||
final AbsolutePath path = AbsolutePath('/');
|
||||
final path = _AbsolutePath(_sep);
|
||||
SftpClient? client;
|
||||
|
||||
SftpBrowserStatus(SSHClient client) {
|
||||
client.sftp().then((value) => this.client = value);
|
||||
}
|
||||
}
|
||||
|
||||
class _AbsolutePath {
|
||||
String _path;
|
||||
final _prePath = <String>[];
|
||||
|
||||
_AbsolutePath(this._path);
|
||||
|
||||
String get path => _path;
|
||||
|
||||
/// Update path, not set path
|
||||
set path(String newPath) {
|
||||
_prePath.add(_path);
|
||||
if (newPath == '..') {
|
||||
_path = _path.substring(0, _path.lastIndexOf(_sep));
|
||||
if (_path == '') {
|
||||
_path = _sep;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (newPath.startsWith(_sep)) {
|
||||
_path = newPath;
|
||||
return;
|
||||
}
|
||||
_path = _path.joinPath(newPath, seperator: _sep);
|
||||
}
|
||||
|
||||
bool undo() {
|
||||
if (_prePath.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
_path = _prePath.removeLast();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user