1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
636 B
Go

//go:build !windows
package history
import (
"io"
"os"
"path/filepath"
)
const historyFile = ".rqlite_history"
2 years ago
// Reader returns a reader of the history file.
func Reader() io.ReadCloser {
hdir, err := os.UserHomeDir()
if err != nil {
return nil
}
f, err := os.Open(filepath.Join(hdir, historyFile))
if err != nil {
return nil
}
return f
}
2 years ago
// Writer returns a writer for the history file.
func Writer() io.WriteCloser {
hdir, err := os.UserHomeDir()
if err != nil {
return nil
}
f, err := os.OpenFile(filepath.Join(hdir, historyFile), os.O_RDWR|os.O_CREATE, 0755)
if err != nil {
return nil
}
return f
}