Introduce first class support for Android (#5772)

This commit is contained in:
Fredrik Høisæther Rasch 2017-08-06 02:18:15 +02:00 • committed by Andreas Rumpf
commit c39e202976
15 changed files with 109 additions and 14 deletions

View file

@ -528,11 +528,26 @@ when declared(getEnv) or defined(nimscript):
elif getEnv("XDG_CONFIG_DIR"): return string(getEnv("XDG_CONFIG_DIR")) & "/"
else: return string(getEnv("HOME")) & "/.config/"
when defined(android):
{.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect, WriteDirEffect].}
elif defined(windows):
{.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect].}
else:
{.pragma: getTempDirEffects, tags: [ReadIOEffect].}
proc getTempDir*(): string {.rtl, extern: "nos$1",
tags: [ReadEnvEffect, ReadIOEffect].} =
getTempDirEffects.} =
## Returns the temporary directory of the current user for applications to
## save temporary files in.
when defined(windows): return string(getEnv("TEMP")) & "\\"
when defined(tempDir):
const tempDir {.strdefine.}: string = nil
return tempDir
elif defined(windows): return string(getEnv("TEMP")) & "\\"
elif defined(android):
let tempDir = getHomeDir() / "nimtempfs"
try: createDir(tempDir)
except OSError: discard
return tempDir
else: return "/tmp/"
proc expandTilde*(path: string): string {.