Skip to content

Commit

Permalink
Fixed explorer paths for older windows builds #46
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrot committed Aug 4, 2022
1 parent abdac7e commit 7530657
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/components/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class WSLApi {
/// Start Explorer
/// @param distribution: String
void startExplorer(String distribution, {String path = ''}) async {
String fullPath = '\\\\wsl.localhost\\$distribution';
String fullPath = '$explorerPath\\$distribution';
if (path != '') {
path = path.replaceAll('/', '\\');
fullPath += path;
Expand Down
2 changes: 2 additions & 0 deletions lib/components/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const String defaultRepoLink =
const String gitRepoLink =
'https://raw.githubusercontent.com/bostrot/wsl2-distro-manager/main/images.json';

String explorerPath = '\\\\wsl.localhost';

// https://docs.microsoft.com/en-us/windows/wsl/install-on-server
Map<String, String> distroRootfsLinks = {
'Ubuntu 21.04':
Expand Down
10 changes: 9 additions & 1 deletion lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,22 @@ class _MyHomePageState extends State<MyHomePage> {
} else {
exec = "git";
}
var tmpPlatform = platform;
int? build;
try {
if (int.parse(platform.split('Build ')[1].split(')')[0]) >= 22000) {
platform = platform
tmpPlatform = platform
.replaceAll('Windows 10', 'Windows 11')
.replaceAll('10.0', '11.0');
}
build = int.tryParse(platform.split('Build ')[1].split(')')[0]);
if (build != null && build < 21354) {
explorerPath = "\\\\wsl\$";
}
} catch (e) {
// Empty path
} finally {
platform = tmpPlatform;
}

// Enable analytics
Expand Down

0 comments on commit 7530657

Please sign in to comment.