mirror of
				https://github.com/kaspanet/kaspad.git
				synced 2025-10-14 00:59:33 +00:00 
			
		
		
		
	 f46dec449d
			
		
	
	
		f46dec449d
		
	
	
	
	
		
			
			* [NOD-510] Change coinbase flags to kaspad. * [NOD-510] Removed superfluous spaces after periods in comments. * [NOD-510] Rename btcd -> kaspad in the root folder. * [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode. * [NOD-510] Rename BtcEncode -> KaspaEncode and BtcDecode -> KaspaDecode. * [NOD-510] Continue renaming btcd -> kaspad. * [NOD-510] Rename btcjson -> kaspajson. * [NOD-510] Rename file names inside kaspajson. * [NOD-510] Rename kaspajson -> jsonrpc. * [NOD-510] Finish renaming in addrmgr. * [NOD-510] Rename package btcec to ecc. * [NOD-510] Finish renaming stuff in blockdag. * [NOD-510] Rename stuff in cmd. * [NOD-510] Rename stuff in config. * [NOD-510] Rename stuff in connmgr. * [NOD-510] Rename stuff in dagconfig. * [NOD-510] Rename stuff in database. * [NOD-510] Rename stuff in docker. * [NOD-510] Rename stuff in integration. * [NOD-510] Rename jsonrpc to rpcmodel. * [NOD-510] Rename stuff in limits. * [NOD-510] Rename stuff in logger. * [NOD-510] Rename stuff in mempool. * [NOD-510] Rename stuff in mining. * [NOD-510] Rename stuff in netsync. * [NOD-510] Rename stuff in peer. * [NOD-510] Rename stuff in release. * [NOD-510] Rename stuff in rpcclient. * [NOD-510] Rename stuff in server. * [NOD-510] Rename stuff in signal. * [NOD-510] Rename stuff in txscript. * [NOD-510] Rename stuff in util. * [NOD-510] Rename stuff in wire. * [NOD-510] Fix failing tests. * [NOD-510] Fix merge errors. * [NOD-510] Fix go vet errors. * [NOD-510] Remove merged file that's no longer relevant. * [NOD-510] Add a comment above Op0. * [NOD-510] Fix some comments referencing Bitcoin Core. * [NOD-510] Fix some more comments referencing Bitcoin Core. * [NOD-510] Fix bitcoin -> kaspa. * [NOD-510] Fix more bitcoin -> kaspa. * [NOD-510] Fix comments, remove DisconnectBlock in addrindex. * [NOD-510] Rename KSPD to KASD. * [NOD-510] Fix comments and user agent.
		
			
				
	
	
		
			106 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright (c) 2013-2017 The btcsuite developers
 | |
| // Use of this source code is governed by an ISC
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| package util
 | |
| 
 | |
| import (
 | |
| 	"os"
 | |
| 	"os/user"
 | |
| 	"path/filepath"
 | |
| 	"runtime"
 | |
| 	"strings"
 | |
| 	"unicode"
 | |
| )
 | |
| 
 | |
| // appDataDir returns an operating system specific directory to be used for
 | |
| // storing application data for an application. See AppDataDir for more
 | |
| // details. This unexported version takes an operating system argument
 | |
| // primarily to enable the testing package to properly test the function by
 | |
| // forcing an operating system that is not the currently one.
 | |
| func appDataDir(goos, appName string, roaming bool) string {
 | |
| 	if appName == "" || appName == "." {
 | |
| 		return "."
 | |
| 	}
 | |
| 
 | |
| 	// The caller really shouldn't prepend the appName with a period, but
 | |
| 	// if they do, handle it gracefully by trimming it.
 | |
| 	appName = strings.TrimPrefix(appName, ".")
 | |
| 	appNameUpper := string(unicode.ToUpper(rune(appName[0]))) + appName[1:]
 | |
| 	appNameLower := string(unicode.ToLower(rune(appName[0]))) + appName[1:]
 | |
| 
 | |
| 	// Get the OS specific home directory via the Go standard lib.
 | |
| 	var homeDir string
 | |
| 	usr, err := user.Current()
 | |
| 	if err == nil {
 | |
| 		homeDir = usr.HomeDir
 | |
| 	}
 | |
| 
 | |
| 	// Fall back to standard HOME environment variable that works
 | |
| 	// for most POSIX OSes if the directory from the Go standard
 | |
| 	// lib failed.
 | |
| 	if err != nil || homeDir == "" {
 | |
| 		homeDir = os.Getenv("HOME")
 | |
| 	}
 | |
| 
 | |
| 	switch goos {
 | |
| 	// Attempt to use the LOCALAPPDATA or APPDATA environment variable on
 | |
| 	// Windows.
 | |
| 	case "windows":
 | |
| 		// Windows XP and before didn't have a LOCALAPPDATA, so fallback
 | |
| 		// to regular APPDATA when LOCALAPPDATA is not set.
 | |
| 		appData := os.Getenv("LOCALAPPDATA")
 | |
| 		if roaming || appData == "" {
 | |
| 			appData = os.Getenv("APPDATA")
 | |
| 		}
 | |
| 
 | |
| 		if appData != "" {
 | |
| 			return filepath.Join(appData, appNameUpper)
 | |
| 		}
 | |
| 
 | |
| 	case "darwin":
 | |
| 		if homeDir != "" {
 | |
| 			return filepath.Join(homeDir, "Library",
 | |
| 				"Application Support", appNameUpper)
 | |
| 		}
 | |
| 
 | |
| 	case "plan9":
 | |
| 		if homeDir != "" {
 | |
| 			return filepath.Join(homeDir, appNameLower)
 | |
| 		}
 | |
| 
 | |
| 	default:
 | |
| 		if homeDir != "" {
 | |
| 			return filepath.Join(homeDir, "."+appNameLower)
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	// Fall back to the current directory if all else fails.
 | |
| 	return "."
 | |
| }
 | |
| 
 | |
| // AppDataDir returns an operating system specific directory to be used for
 | |
| // storing application data for an application.
 | |
| //
 | |
| // The appName parameter is the name of the application the data directory is
 | |
| // being requested for. This function will prepend a period to the appName for
 | |
| // POSIX style operating systems since that is standard practice. An empty
 | |
| // appName or one with a single dot is treated as requesting the current
 | |
| // directory so only "." will be returned. Further, the first character
 | |
| // of appName will be made lowercase for POSIX style operating systems and
 | |
| // uppercase for Mac and Windows since that is standard practice.
 | |
| //
 | |
| // The roaming parameter only applies to Windows where it specifies the roaming
 | |
| // application data profile (%APPDATA%) should be used instead of the local one
 | |
| // (%LOCALAPPDATA%) that is used by default.
 | |
| //
 | |
| // Example results:
 | |
| //  dir := AppDataDir("myapp", false)
 | |
| //   POSIX (Linux/BSD): ~/.myapp
 | |
| //   Mac OS: $HOME/Library/Application Support/Myapp
 | |
| //   Windows: %LOCALAPPDATA%\Myapp
 | |
| //   Plan 9: $home/myapp
 | |
| func AppDataDir(appName string, roaming bool) string {
 | |
| 	return appDataDir(runtime.GOOS, appName, roaming)
 | |
| }
 |