Add HomeDir function
This commit is contained in:
parent
4ae938ada9
commit
4f1b3206c5
6 changed files with 92 additions and 21 deletions
49
raylib/utils_windows.go
Normal file
49
raylib/utils_windows.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
// +build windows
|
||||
|
||||
package raylib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Log message types
|
||||
const (
|
||||
LogInfo = iota
|
||||
LogError
|
||||
LogWarning
|
||||
LogDebug
|
||||
)
|
||||
|
||||
var traceDebugMsgs = false
|
||||
|
||||
// Set debug messages
|
||||
func SetDebug(enabled bool) {
|
||||
traceDebugMsgs = enabled
|
||||
}
|
||||
|
||||
// Trace log
|
||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||
switch msgType {
|
||||
case LogInfo:
|
||||
fmt.Printf("INFO: "+text+"\n", v...)
|
||||
case LogError:
|
||||
fmt.Printf("ERROR: "+text+"\n", v...)
|
||||
os.Exit(1)
|
||||
case LogWarning:
|
||||
fmt.Printf("WARNING: "+text+"\n", v...)
|
||||
case LogDebug:
|
||||
if traceDebugMsgs {
|
||||
fmt.Printf("DEBUG: "+text+"\n", v...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HomeDir returns user home directory
|
||||
func HomeDir() string {
|
||||
home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
|
||||
if home == "" {
|
||||
home = os.Getenv("USERPROFILE")
|
||||
}
|
||||
return home
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue