about summary refs log tree commit diff stats
path: root/src/extern
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-14 01:41:47 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-14 02:01:21 +0200
commitc1b8338045716b25d664c0b8dd91eac0cb76480e (patch)
treea9c0a6763f180c2b6dd380aa880253ffc7685d85 /src/extern
parentdb0798acccbedcef4b16737f6be0cf7388cc0528 (diff)
downloadchawan-c1b8338045716b25d664c0b8dd91eac0cb76480e.tar.gz
move around more modules
* ips -> io/
* loader related stuff -> loader/
* tempfile -> extern/
* buffer, forkserver -> server/
* lineedit, window -> display/
* cell -> types/
* opt -> types/
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