do not follow symlinks on exit

This commit is contained in:
Gokcehan 2016-08-14 15:45:24 +03:00
parent fac1c9e8de
commit bc4c3c127b
2 changed files with 18 additions and 19 deletions

16
app.go
View File

@ -34,6 +34,22 @@ func (app *App) handleInp() {
for {
if gExitFlag {
log.Print("bye!")
if gLastDirPath != "" {
f, err := os.Create(gLastDirPath)
if err != nil {
log.Print(err)
}
defer f.Close()
dir := app.nav.currDir()
_, err = f.WriteString(dir.path)
if err != nil {
log.Print(err)
}
}
return
}
e := app.ui.getExpr()

21
main.go
View File

@ -18,6 +18,7 @@ var (
var (
gExitFlag bool
gLastDirPath string
gSelectionPath string
gSocketPath string
gLogPath string
@ -62,7 +63,7 @@ func startServer() {
func main() {
serverMode := flag.Bool("server", false, "start server (automatic)")
lastDirPath := flag.String("last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gSelectionPath, "selection-path", "", "path to the file to write selected files on exit (to use as open file dialog)")
flag.Parse()
@ -78,22 +79,4 @@ func main() {
client()
}
if *lastDirPath != "" {
f, err := os.Create(*lastDirPath)
if err != nil {
log.Print(err)
}
defer f.Close()
wd, err := os.Getwd()
if err != nil {
log.Print(err)
}
_, err = f.WriteString(wd)
if err != nil {
log.Print(err)
}
}
}