GetProgramDataDirectory()
Verfasst: 02.12.2015 18:33
Es gibt zwar in PureBasic die Funktion um das Home-Verzeichnis zu bestimmen, aber unter Windows und Mac ist es nicht das Verzeichnis, wo man seine Programm-Einstellungen etc. unterbringen sollte.
Der Code basiert auf diesen Thread http://www.purebasic.fr/german/viewtopi ... =8&t=27741 ich hab es nur umformuliert
Nebenbei wird noch eine #Slash Konstante definiert, da ja dies auch OS-Abhängig ist. Ok, windows ist da toleranter und akzeptiert auch /
Der Code basiert auf diesen Thread http://www.purebasic.fr/german/viewtopi ... =8&t=27741 ich hab es nur umformuliert
Nebenbei wird noch eine #Slash Konstante definiert, da ja dies auch OS-Abhängig ist. Ok, windows ist da toleranter und akzeptiert auch /

Code: Alles auswählen
; Description: Return the Program Data directory of os/user
; Author: -
; Date: 02-12-2015
; PB-Version: 5.40
; OS: Windows, Linux, Mac
; English-Forum:
; French-Forum:
; German-Forum:
; -----------------------------------------------------------------------------
; based on this code: http://www.purebasic.fr/german/viewtopic.php?f=8&t=27741
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
#Slash = "\"
CompilerCase #PB_OS_MacOS
#Slash = "/"
CompilerCase #PB_OS_Linux
#Slash = "/"
CompilerEndSelect
Procedure.s GetProgramDataDirectory()
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
ProcedureReturn GetEnvironmentVariable("APPDATA") + "\"
CompilerCase #PB_OS_MacOS
ProcedureReturn GetHomeDirectory() + "Library/Application Support/"
CompilerCase #PB_OS_Linux
ProcedureReturn GetHomeDirectory() +"."
CompilerEndSelect
EndProcedure
;-Example
CompilerIf #PB_Compiler_IsMainFile
path$=GetProgramDataDirectory()
Debug path$
Debug FileSize(path$)
CompilerEndIf