mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
#109 fix: path sep on win
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:r_upgrade/r_upgrade.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
|
||||
import '../data/provider/app.dart';
|
||||
|
||||
@@ -73,16 +73,7 @@ String getTime(int? unixMill) {
|
||||
.replaceFirst('.000', '');
|
||||
}
|
||||
|
||||
/// Join two path with `/`
|
||||
String pathJoin(String path1, String path2) {
|
||||
return path1 + (path1.endsWith('/') ? '' : '/') + path2;
|
||||
}
|
||||
|
||||
String? getHomeDir() {
|
||||
final envVars = Platform.environment;
|
||||
if (isMacOS || isLinux) {
|
||||
return envVars['HOME'];
|
||||
} else if (isWindows) {
|
||||
return envVars['UserProfile'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ enum PlatformType {
|
||||
windows,
|
||||
web,
|
||||
fuchsia,
|
||||
unknown,
|
||||
unknown;
|
||||
}
|
||||
|
||||
final _p = () {
|
||||
@@ -38,7 +38,15 @@ final _p = () {
|
||||
return PlatformType.unknown;
|
||||
}();
|
||||
|
||||
final _pathSep = () {
|
||||
if (Platform.isWindows) {
|
||||
return '\\';
|
||||
}
|
||||
return '/';
|
||||
}();
|
||||
|
||||
PlatformType get platform => _p;
|
||||
String get pathSeparator => _pathSep;
|
||||
|
||||
bool get isAndroid => _p == PlatformType.android;
|
||||
bool get isIOS => _p == PlatformType.ios;
|
||||
@@ -51,3 +59,23 @@ bool get isDesktop =>
|
||||
_p == PlatformType.linux ||
|
||||
_p == PlatformType.macos ||
|
||||
_p == PlatformType.windows;
|
||||
|
||||
/// Available only on desktop,
|
||||
/// return null on mobile
|
||||
String? getHomeDir() {
|
||||
final envVars = Platform.environment;
|
||||
if (isMacOS || isLinux) {
|
||||
return envVars['HOME'];
|
||||
} else if (isWindows) {
|
||||
return envVars['UserProfile'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Join two paths with platform specific separator
|
||||
String pathJoin(String path1, String path2) {
|
||||
if (isWindows) {
|
||||
return path1 + (path1.endsWith('\\') ? '' : '\\') + path2;
|
||||
}
|
||||
return path1 + (path1.endsWith('/') ? '' : '/') + path2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user