From c6676917b308ca23e1154fa1b12bc3a73da471ac Mon Sep 17 00:00:00 2001 From: Li Jie Date: Sat, 6 Sep 2025 22:05:29 +0800 Subject: [PATCH] refine: check msd paths --- internal/flash/flash.go | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/internal/flash/flash.go b/internal/flash/flash.go index d5fc55ab..c00818db 100644 --- a/internal/flash/flash.go +++ b/internal/flash/flash.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "time" @@ -133,12 +134,29 @@ func flashMSD(msd crosscompile.MSD, app string, verbose bool) error { // Find the MSD volume var mountPoint string for _, volumeName := range msd.VolumeName { - // Try common mount points on different platforms - candidates := []string{ - filepath.Join("/Volumes", volumeName), // macOS - filepath.Join("/media", os.Getenv("USER"), volumeName), // Linux - filepath.Join("/mnt", volumeName), // Linux alternative - volumeName + ":", // Windows (assuming drive letter) + // Try platform-specific mount points + var candidates []string + switch runtime.GOOS { + case "darwin": + candidates = []string{ + filepath.Join("/Volumes", volumeName), + } + case "linux": + candidates = []string{ + filepath.Join("/media", os.Getenv("USER"), volumeName), + filepath.Join("/mnt", volumeName), + } + case "windows": + candidates = []string{ + volumeName + ":", + } + default: + candidates = []string{ + filepath.Join("/Volumes", volumeName), // macOS + filepath.Join("/media", os.Getenv("USER"), volumeName), // Linux + filepath.Join("/mnt", volumeName), // Linux alternative + volumeName + ":", // Windows + } } for _, candidate := range candidates {