about summary refs log tree commit diff stats
path: root/src/extern
diff options
context:
space:
mode:
Diffstat (limited to 'src/extern')
-rw-r--r--src/extern/editor.nim2
-rw-r--r--src/extern/tempfile.nim18
2 files changed, 19 insertions, 1 deletions
diff --git a/src/extern/editor.nim b/src/extern/editor.nim
index 58f3d199..345b1d67 100644
--- a/src/extern/editor.nim
+++ b/src/extern/editor.nim
@@ -3,7 +3,7 @@ import os
 import config/config
 import display/term
 import extern/runproc
-import io/tempfile
+import extern/tempfile
 
 func formatEditorName(editor, file: string, line: int): string =
   result = newStringOfCap(editor.len + file.len)
diff --git a/src/extern/tempfile.nim b/src/extern/tempfile.nim
new file mode 100644
index 00000000..d99ea4dc
--- /dev/null
+++ b/src/extern/tempfile.nim
@@ -0,0 +1,18 @@
+import os
+
+var tmpf_seq: int
+proc getTempFile*(tmpdir: string, ext = ""): string =
+  if not dirExists(tmpdir):
+    createDir(tmpdir)
+  var tmpf = tmpdir / "chatmp" & $tmpf_seq
+  if ext != "":
+    tmpf &= "."
+    tmpf &= ext
+  while fileExists(tmpf):
+    inc tmpf_seq
+    tmpf = tmpdir / "chatmp" & $tmpf_seq
+    if ext != "":
+      tmpf &= "."
+      tmpf &= ext
+  inc tmpf_seq
+  return tmpf