From c1b8338045716b25d664c0b8dd91eac0cb76480e Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 14 Sep 2023 01:41:47 +0200 Subject: move around more modules * ips -> io/ * loader related stuff -> loader/ * tempfile -> extern/ * buffer, forkserver -> server/ * lineedit, window -> display/ * cell -> types/ * opt -> types/ --- src/extern/editor.nim | 2 +- src/extern/tempfile.nim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/extern/tempfile.nim (limited to 'src/extern') 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 -- cgit 1.4.1-2-gfad0