~aleteoryx/tclircc

ref: 592f2b1342c0ea9a4af15accfe18f69e2f76b5ab tclircc/db/main.tcl -rw-r--r-- 748 bytes
592f2b13aleteoryx readme changes a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package require sqlite3
package require logger

set log [logger::init tclircc::db]

switch -- [set tcl_platform(platform)] {
  "windows" {
    set data_dir "[set env(APPDATA)][file separator]tclircc"
  }
  "unix" {
    if [info exists env(XDG_CONFIG_HOME)] {
      set data_dir "[set env(XDG_CONFIG_HOME)][file separator]tclircc"
    } elseif [info exists env(HOME)] {
      set data_dir "[set env(HOME)][file separator].config[file separator]tclircc"
    } else {
      return -code error {Missing $HOME or $XDG_CONFIG_HOME, can't store config!}
    }
  }
  default {
    return -code error {Unknown platform, can't store config.}
  }
}

file mkdir $data_dir

proc path_to_core {} {
  global data_dir
  return "$data_dir[file separator]core.db"
}