Пример #1
0
// Save the history to a file.
func SaveHistory(path string) error {
	p := C.CString(path)
	e := C.write_history(p)
	C.free(unsafe.Pointer(p))

	if e == 0 {
		return nil
	}
	return syscall.Errno(e)
}
Пример #2
0
// Save a readline history file.
// The default filename is ~/.history.
func WriteHistoryFile(s string) error {
	p := C.CString(s)
	defer C.free(unsafe.Pointer(p))
	errno := C.write_history(p)
	if errno == 0 && HistoryLength >= 0 {
		errno = C.history_truncate_file(p, C.int(HistoryLength))
	}
	if errno == 0 {
		return nil
	}
	return syscall.Errno(errno)
}
Пример #3
0
// WriteHistory writes the current history to filename, overwriting filename if necessary.
// If filename is "", then write the history list to `~/.history'.
// (See write_history http://cnswww.cns.cwru.edu/php/chet/readline/history.html#IDX29)
func WriteHistory(filename string) error {
	if HistoryLength() <= 0 {
		return nil
	}
	var cfilename *C.char
	if len(filename) != 0 {
		cfilename = C.CString(filename)
	}
	err := C.write_history(cfilename)
	if cfilename != nil {
		C.free(unsafe.Pointer(cfilename))
	}
	if err != 0 {
		return syscall.Errno(err)
	}
	return nil
}
Пример #4
0
func WriteHistoryToFile(fileName string) {
	cFileName := C.CString(fileName)
	C.write_history(cFileName)
	C.free(unsafe.Pointer(cFileName))
}