Skip to content

Commit

Permalink
fix: add file on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
No06 committed Nov 14, 2024
1 parent 00d303a commit 7dda63a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/data/model/app/path_with_prefix.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'package:fl_lib/fl_lib.dart';

final _seperator = Pfs.seperator;

/// It's used on platform's file system.
/// So use [Platform.pathSeparator] to join path.
class LocalPath {
final String _prefixPath;
String _path = '/';
String _path = _seperator;
String? _prePath;
String get path => _prefixPath + _path;

Expand All @@ -13,20 +15,20 @@ class LocalPath {
void update(String newPath) {
_prePath = _path;
if (newPath == '..') {
_path = _path.substring(0, _path.lastIndexOf('/'));
_path = _path.substring(0, _path.lastIndexOf(_seperator));
if (_path == '') {
_path = '/';
_path = _seperator;
}
return;
}
if (newPath == '/') {
_path = '/';
if (newPath == _seperator) {
_path = _seperator;
return;
}
_path = _path.joinPath(newPath);
}

bool get canBack => path != '$_prefixPath/';
bool get canBack => path != '$_prefixPath$_seperator';

bool undo() {
if (_prePath == null || _path == _prePath) {
Expand All @@ -38,7 +40,7 @@ class LocalPath {
}

String _trimSuffix(String prefixPath) {
if (prefixPath.endsWith('/')) {
if (prefixPath.endsWith(_seperator)) {
return prefixPath.substring(0, prefixPath.length - 1);
}
return prefixPath;
Expand Down

0 comments on commit 7dda63a

Please sign in to comment.