mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
make ospaths compile for Android again, simplify its implementation, added a disclaimer
This commit is contained in:
@@ -528,28 +528,20 @@ 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):
|
||||
when declared(os):
|
||||
{.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect, WriteDirEffect].}
|
||||
else:
|
||||
{.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect].}
|
||||
elif defined(windows):
|
||||
{.pragma: getTempDirEffects, tags: [ReadEnvEffect, ReadIOEffect].}
|
||||
else:
|
||||
{.pragma: getTempDirEffects, tags: [ReadIOEffect].}
|
||||
|
||||
proc getTempDir*(): string {.rtl, extern: "nos$1",
|
||||
getTempDirEffects.} =
|
||||
tags: [ReadEnvEffect, ReadIOEffect].} =
|
||||
## Returns the temporary directory of the current user for applications to
|
||||
## save temporary files in.
|
||||
##
|
||||
## **Please do not use this**: On Android, it currently
|
||||
## returns ``getHomeDir()``, and on other Unix based systems it can cause
|
||||
## security problems too. That said, you can override this implementation
|
||||
## by adding ``-d:tempDir=mytempname`` to your compiler invokation.
|
||||
when defined(tempDir):
|
||||
const tempDir {.strdefine.}: string = nil
|
||||
return tempDir
|
||||
elif defined(windows): return string(getEnv("TEMP")) & "\\"
|
||||
elif defined(android):
|
||||
let tempDir = getHomeDir() / "nimtempfs"
|
||||
createDir(tempDir)
|
||||
return tempDir
|
||||
elif defined(android): return getHomeDir()
|
||||
else: return "/tmp/"
|
||||
|
||||
proc expandTilde*(path: string): string {.
|
||||
|
||||
Reference in New Issue
Block a user