mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: add file on windows
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import 'package:fl_lib/fl_lib.dart';
|
import 'package:fl_lib/fl_lib.dart';
|
||||||
|
|
||||||
|
final _seperator = Pfs.seperator;
|
||||||
|
|
||||||
/// It's used on platform's file system.
|
/// It's used on platform's file system.
|
||||||
/// So use [Platform.pathSeparator] to join path.
|
/// So use [Platform.pathSeparator] to join path.
|
||||||
class LocalPath {
|
class LocalPath {
|
||||||
final String _prefixPath;
|
final String _prefixPath;
|
||||||
String _path = '/';
|
String _path = _seperator;
|
||||||
String? _prePath;
|
String? _prePath;
|
||||||
String get path => _prefixPath + _path;
|
String get path => _prefixPath + _path;
|
||||||
|
|
||||||
@@ -13,20 +15,20 @@ class LocalPath {
|
|||||||
void update(String newPath) {
|
void update(String newPath) {
|
||||||
_prePath = _path;
|
_prePath = _path;
|
||||||
if (newPath == '..') {
|
if (newPath == '..') {
|
||||||
_path = _path.substring(0, _path.lastIndexOf('/'));
|
_path = _path.substring(0, _path.lastIndexOf(_seperator));
|
||||||
if (_path == '') {
|
if (_path == '') {
|
||||||
_path = '/';
|
_path = _seperator;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newPath == '/') {
|
if (newPath == _seperator) {
|
||||||
_path = '/';
|
_path = _seperator;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_path = _path.joinPath(newPath);
|
_path = _path.joinPath(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get canBack => path != '$_prefixPath/';
|
bool get canBack => path != '$_prefixPath$_seperator';
|
||||||
|
|
||||||
bool undo() {
|
bool undo() {
|
||||||
if (_prePath == null || _path == _prePath) {
|
if (_prePath == null || _path == _prePath) {
|
||||||
@@ -38,7 +40,7 @@ class LocalPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _trimSuffix(String prefixPath) {
|
String _trimSuffix(String prefixPath) {
|
||||||
if (prefixPath.endsWith('/')) {
|
if (prefixPath.endsWith(_seperator)) {
|
||||||
return prefixPath.substring(0, prefixPath.length - 1);
|
return prefixPath.substring(0, prefixPath.length - 1);
|
||||||
}
|
}
|
||||||
return prefixPath;
|
return prefixPath;
|
||||||
|
|||||||
Reference in New Issue
Block a user