Moved the windows stuff to separate file
This commit is contained in:
parent
eed78633aa
commit
436813798a
26
user/user.go
26
user/user.go
|
@ -5,8 +5,6 @@ import (
|
|||
"os"
|
||||
"runtime"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"git.martyn.berlin/martyn/directories/base"
|
||||
)
|
||||
|
||||
|
@ -22,8 +20,7 @@ func Audio() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Music, 0)
|
||||
return path, err
|
||||
return windowsAudio()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Music", err
|
||||
|
@ -39,8 +36,7 @@ func Desktop() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Desktop, 0)
|
||||
return path, err
|
||||
return windowsDesktop()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Desktop", err
|
||||
|
@ -56,8 +52,7 @@ func Documents() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Documents, 0)
|
||||
return path, err
|
||||
return windowsDocuments()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Documents", err
|
||||
|
@ -73,8 +68,7 @@ func Downloads() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Downloads, 0)
|
||||
return path, err
|
||||
return windowsDownloads()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Downloads", err
|
||||
|
@ -109,8 +103,7 @@ func Pictures() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Pictures, 0)
|
||||
return path, err
|
||||
return windowsPictures()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Pictures", err
|
||||
|
@ -126,8 +119,7 @@ func Public() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Public, 0)
|
||||
return path, err
|
||||
return windowsPublic()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Public", err
|
||||
|
@ -143,8 +135,7 @@ func Templates() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Templates, 0)
|
||||
return path, err
|
||||
return windowsTemplates()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Templates", err
|
||||
|
@ -160,8 +151,7 @@ func Videos() (string, error) {
|
|||
return e, nil
|
||||
}
|
||||
case "windows":
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Videos, 0)
|
||||
return path, err
|
||||
return windowsVideos()
|
||||
case "darwin":
|
||||
h, err := Home()
|
||||
return h + "/Videos", err
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package user
|
||||
|
||||
import "errors"
|
||||
|
||||
func wrongPlatform() (string, error) {
|
||||
return "", errors.New("using windows call on non-windows system")
|
||||
}
|
||||
|
||||
func windowsAudio() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsDesktop() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsDocuments() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsDownloads() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsPictures() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsPublic() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsTemplates() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
||||
|
||||
func windowsVideos() (string, error) {
|
||||
return wrongPlatform()
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package user
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
func windowsAudio() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Music, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsDesktop() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Desktop, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsDocuments() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Documents, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsDownloads() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Downloads, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsPictures() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Pictures, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsPublic() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Public, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsTemplates() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Templates, 0)
|
||||
return path, err
|
||||
}
|
||||
|
||||
func windowsVideos() (string, error) {
|
||||
path, err := windows.KnownFolderPath(windows.FOLDERID_Videos, 0)
|
||||
return path, err
|
||||
}
|
Loading…
Reference in New Issue