mirror of
https://github.com/turtlemonvh/tnnlr.git
synced 2021-09-26 15:22:24 +03:00
35 lines
583 B
Go
35 lines
583 B
Go
package tnnlr
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/mitchellh/go-homedir"
|
|
)
|
|
|
|
/*
|
|
Bookkeeping operations for tnnlr.
|
|
Logging and pid tracking for launched processes.
|
|
*/
|
|
|
|
var baseDir = "~/.tnnlr"
|
|
|
|
var relProc = "proc"
|
|
var relLog = "log"
|
|
|
|
func getRelativePath(subdir string) (string, error) {
|
|
basePath, err := homedir.Expand(baseDir)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(basePath, subdir), nil
|
|
}
|
|
|
|
func createRelDir(subdir string) error {
|
|
procDir, err := getRelativePath(subdir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return os.MkdirAll(procDir, os.ModePerm)
|
|
}
|