fix file transfer local Windows path can't split
This commit is contained in:
parent
5b9a76f8a5
commit
c79b6eb0bb
@ -825,7 +825,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
final x = offset.dx;
|
||||
final y = offset.dy + size.height + 1;
|
||||
|
||||
final isPeerWindows = isWindows(isLocal);
|
||||
final isPeerWindows = model.getCurrentIsWindows(isLocal);
|
||||
final List<MenuEntryBase> menuItems = [
|
||||
MenuEntryButton(
|
||||
childBuilder: (TextStyle? style) => isPeerWindows
|
||||
@ -913,7 +913,8 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
bool isLocal, void Function(List<String>) onPressed) {
|
||||
final path = model.getCurrentDir(isLocal).path;
|
||||
final breadCrumbList = List<BreadCrumbItem>.empty(growable: true);
|
||||
if (isWindows(isLocal) && path == '/') {
|
||||
final isWindows = model.getCurrentIsWindows(isLocal);
|
||||
if (isWindows && path == '/') {
|
||||
breadCrumbList.add(BreadCrumbItem(
|
||||
content: TextButton(
|
||||
child: buildWindowsThisPC(),
|
||||
@ -922,7 +923,7 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
onPressed: () => onPressed(['/']))
|
||||
.marginSymmetric(horizontal: 4)));
|
||||
} else {
|
||||
final list = PathUtil.split(path, model.getCurrentIsWindows(isLocal));
|
||||
final list = PathUtil.split(path, isWindows);
|
||||
breadCrumbList.addAll(list.asMap().entries.map((e) => BreadCrumbItem(
|
||||
content: TextButton(
|
||||
child: Text(e.value),
|
||||
@ -934,14 +935,6 @@ class _FileManagerPageState extends State<FileManagerPage>
|
||||
return breadCrumbList;
|
||||
}
|
||||
|
||||
bool isWindows(bool isLocal) {
|
||||
if (isLocal) {
|
||||
return Platform.isWindows;
|
||||
} else {
|
||||
return _ffi.ffiModel.pi.platform.toLowerCase() == "windows";
|
||||
}
|
||||
}
|
||||
|
||||
breadCrumbScrollToEnd(bool isLocal) {
|
||||
Future.delayed(Duration(milliseconds: 200), () {
|
||||
final breadCrumbScroller = getBreadCrumbScrollController(isLocal);
|
||||
|
@ -138,7 +138,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
model.currentShowHidden
|
||||
model.getCurrentShowHidden()
|
||||
? Icons.check_box_outlined
|
||||
: Icons.check_box_outline_blank,
|
||||
color: Theme.of(context).iconTheme.color),
|
||||
@ -185,7 +185,8 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
model.createDir(PathUtil.join(
|
||||
model.currentDir.path,
|
||||
name.value.text,
|
||||
model.currentIsWindows));
|
||||
model
|
||||
.getCurrentIsWindows()));
|
||||
close();
|
||||
}
|
||||
},
|
||||
@ -351,12 +352,12 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
if (model.currentHome.startsWith(list[0])) {
|
||||
// absolute path
|
||||
for (var item in list) {
|
||||
path = PathUtil.join(path, item, model.currentIsWindows);
|
||||
path = PathUtil.join(path, item, model.getCurrentIsWindows());
|
||||
}
|
||||
} else {
|
||||
path += model.currentHome;
|
||||
for (var item in list) {
|
||||
path = PathUtil.join(path, item, model.currentIsWindows);
|
||||
path = PathUtil.join(path, item, model.getCurrentIsWindows());
|
||||
}
|
||||
}
|
||||
model.openDirectory(path);
|
||||
@ -500,7 +501,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
|
||||
List<BreadCrumbItem> getPathBreadCrumbItems(
|
||||
void Function() onHome, void Function(List<String>) onPressed) {
|
||||
final path = model.currentShortPath;
|
||||
final list = PathUtil.split(path, model.currentIsWindows);
|
||||
final list = PathUtil.split(path, model.getCurrentIsWindows());
|
||||
final breadCrumbList = [
|
||||
BreadCrumbItem(
|
||||
content: IconButton(
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
@ -144,18 +145,14 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
bool get currentShowHidden =>
|
||||
_isSelectedLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
|
||||
bool getCurrentShowHidden(bool isLocal) {
|
||||
return isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
bool getCurrentShowHidden([bool? isLocal]) {
|
||||
final isLocal_ = isLocal ?? _isSelectedLocal;
|
||||
return isLocal_ ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
}
|
||||
|
||||
bool get currentIsWindows =>
|
||||
_isSelectedLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
|
||||
bool getCurrentIsWindows(bool isLocal) {
|
||||
return isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
bool getCurrentIsWindows([bool? isLocal]) {
|
||||
final isLocal_ = isLocal ?? _isSelectedLocal;
|
||||
return isLocal_ ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
}
|
||||
|
||||
final _fileFetcher = FileFetcher();
|
||||
@ -330,13 +327,13 @@ class FileModel extends ChangeNotifier {
|
||||
_localOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "local_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_localOption.isWindows = Platform.isWindows;
|
||||
|
||||
_remoteOption.showHidden = (await bind.sessionGetPeerOption(
|
||||
id: parent.target?.id ?? "", name: "remote_show_hidden"))
|
||||
.isNotEmpty;
|
||||
_remoteOption.isWindows = parent.target?.ffiModel.pi.platform == "Windows";
|
||||
|
||||
debugPrint("remote platform: ${parent.target?.ffiModel.pi.platform}");
|
||||
_remoteOption.isWindows =
|
||||
parent.target?.ffiModel.pi.platform.toLowerCase() == "windows";
|
||||
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
|
||||
@ -404,14 +401,10 @@ class FileModel extends ChangeNotifier {
|
||||
if (!isBack) {
|
||||
pushHistory(isLocal);
|
||||
}
|
||||
final showHidden =
|
||||
isLocal ? _localOption.showHidden : _remoteOption.showHidden;
|
||||
final isWindows =
|
||||
isLocal ? _localOption.isWindows : _remoteOption.isWindows;
|
||||
final showHidden = getCurrentShowHidden(isLocal);
|
||||
final isWindows = getCurrentIsWindows(isLocal);
|
||||
// process /C:\ -> C:\ on Windows
|
||||
if (isLocal
|
||||
? _localOption.isWindows
|
||||
: _remoteOption.isWindows && path.length > 1 && path[0] == '/') {
|
||||
if (isWindows && path.length > 1 && path[0] == '/') {
|
||||
path = path.substring(1);
|
||||
if (path[path.length - 1] != '\\') {
|
||||
path = "$path\\";
|
||||
|
Loading…
x
Reference in New Issue
Block a user