예제 #1
0
// ReadHistory loads a readline history file.
// The default filename is ~/.history.
func ReadHistoryFile(s string) error {
	p := C.CString(s)
	defer C.free(unsafe.Pointer(p))
	if errno := C.read_history(p); errno != 0 {
		return syscall.Errno(errno)
	}
	return nil
}
예제 #2
0
파일: readline.go 프로젝트: ZhuHangpeng/mig
// Load the history from a file.
func LoadHistory(path string) error {
	p := C.CString(path)
	e := C.read_history(p)
	C.free(unsafe.Pointer(p))

	if e == 0 {
		return nil
	}
	return syscall.Errno(e)
}
예제 #3
0
파일: history.go 프로젝트: gwenn/goreadline
// ReadHistory adds the content of filename to the history list, a line at a time.
// If filename is "", then read from '~/.history'.
// (See read_history http://cnswww.cns.cwru.edu/php/chet/readline/history.html#IDX27)
func ReadHistory(filename string) (bool, error) {
	var cfilename *C.char
	if len(filename) != 0 {
		cfilename = C.CString(filename)
	}
	err := C.read_history(cfilename)
	if cfilename != nil {
		C.free(unsafe.Pointer(cfilename))
	}
	if err != 0 {
		e := syscall.Errno(err)
		if e == syscall.ENOENT { // ignored when the file doesn't exist.
			return false, nil
		}
		return false, e
	}
	return true, nil
}
예제 #4
0
func LoadHistoryFromFile(fileName string) {
	cFileName := C.CString(fileName)
	C.read_history(cFileName)
	C.free(unsafe.Pointer(cFileName))
}