Пример #1
0
func (lock *LockIMP) Obtain() error {
	self := (*C.lucy_Lock)(clownfish.Unwrap(lock, "lock"))
	success := C.LUCY_Lock_Obtain(self)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Пример #2
0
func (fh *FileHandleIMP) Window(window FileWindow, offset, length int64) error {
	self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
	windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
	success := C.LUCY_FH_Window(self, windowC, C.int64_t(offset), C.int64_t(length))
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Пример #3
0
func (fh *FileHandleIMP) ReleaseWindow(window FileWindow) error {
	self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
	windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
	success := C.LUCY_FH_Release_Window(self, windowC)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Пример #4
0
func (f *FolderIMP) LocalMkDir(name string) error {
	self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
	nameC := (*C.cfish_String)(clownfish.GoToClownfish(name, unsafe.Pointer(C.CFISH_STRING), false))
	defer C.cfish_decref(unsafe.Pointer(nameC))
	success := C.LUCY_Folder_Local_MkDir(self, nameC)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Пример #5
0
func OpenCompoundFileReader(folder Folder) (reader CompoundFileReader, err error) {
	err = clownfish.TrapErr(func() {
		folderC := (*C.lucy_Folder)(clownfish.Unwrap(folder, "Folder"))
		cfObj := C.lucy_CFReader_open(folderC)
		if cfObj == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		reader = WRAPCompoundFileReader(unsafe.Pointer(cfObj))
	})
	return reader, err
}
Пример #6
0
func (f *FolderIMP) LocalOpenDir() (retval DirHandle, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
		retvalC := C.LUCY_Folder_Local_Open_Dir(self)
		if retvalC == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		retval = WRAPDirHandle(unsafe.Pointer(retvalC))
	})
	return retval, err
}
Пример #7
0
func OpenFSDirHandle(path string) (dh FSDirHandle, err error) {
	err = clownfish.TrapErr(func() {
		pathC := (*C.cfish_String)(clownfish.GoToClownfish(path, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(pathC))
		cfObj := C.lucy_FSDH_open(pathC)
		if cfObj == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		dh = WRAPFSDirHandle(unsafe.Pointer(cfObj))
	})
	return dh, err
}
Пример #8
0
func (f *FolderIMP) HardLink(from, to string) error {
	self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
	fromC := (*C.cfish_String)(clownfish.GoToClownfish(from, unsafe.Pointer(C.CFISH_STRING), false))
	toC := (*C.cfish_String)(clownfish.GoToClownfish(to, unsafe.Pointer(C.CFISH_STRING), false))
	defer C.cfish_decref(unsafe.Pointer(fromC))
	defer C.cfish_decref(unsafe.Pointer(toC))
	success := C.LUCY_Folder_Hard_Link(self, fromC, toC)
	if !success {
		cfErr := C.cfish_Err_get_error()
		return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
	}
	return nil
}
Пример #9
0
func OpenOutStream(file interface{}) (out OutStream, err error) {
	err = clownfish.TrapErr(func() {
		fileC := (*C.cfish_Obj)(clownfish.GoToClownfish(file, unsafe.Pointer(C.CFISH_OBJ), false))
		defer C.cfish_decref(unsafe.Pointer(fileC))
		cfObj := C.lucy_OutStream_open(fileC)
		if cfObj == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		out = WRAPOutStream(unsafe.Pointer(cfObj))
	})
	return out, err
}
Пример #10
0
func OpenRAMFileHandle(path string, flags uint32, ramFile RAMFile) (fh RAMFileHandle, err error) {
	err = clownfish.TrapErr(func() {
		pathC := (*C.cfish_String)(clownfish.GoToClownfish(path, unsafe.Pointer(C.CFISH_STRING), false))
		ramFileC := (*C.lucy_RAMFile)(clownfish.GoToClownfish(ramFile, unsafe.Pointer(C.LUCY_RAMFILE), true))
		defer C.cfish_decref(unsafe.Pointer(pathC))
		cfObj := C.lucy_RAMFH_open(pathC, C.uint32_t(flags), ramFileC)
		if cfObj == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		fh = WRAPRAMFileHandle(unsafe.Pointer(cfObj))
	})
	return fh, err
}
Пример #11
0
func (f *FolderIMP) LocalOpenFileHandle(name string, flags uint32) (retval FileHandle, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
		nameC := (*C.cfish_String)(clownfish.GoToClownfish(name, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(nameC))
		retvalC := C.LUCY_Folder_Local_Open_FileHandle(self, nameC, C.uint32_t(flags))
		if retvalC == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		retval = WRAPFileHandle(unsafe.Pointer(retvalC))
	})
	return retval, err
}
Пример #12
0
func (f *FolderIMP) OpenDir(path string) (retval DirHandle, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
		pathC := (*C.cfish_String)(clownfish.GoToClownfish(path, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(pathC))
		retvalC := C.LUCY_Folder_Open_Dir(self, pathC)
		if retvalC == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		retval = WRAPDirHandle(unsafe.Pointer(retvalC))
	})
	return retval, err
}
Пример #13
0
func (f *FolderIMP) ListR(path string) (retval []string, err error) {
	err = clownfish.TrapErr(func() {
		self := (*C.lucy_Folder)(clownfish.Unwrap(f, "f"))
		pathC := (*C.cfish_String)(clownfish.GoToClownfish(path, unsafe.Pointer(C.CFISH_STRING), false))
		defer C.cfish_decref(unsafe.Pointer(pathC))
		retvalC := C.LUCY_Folder_List_R(self, pathC)
		if retvalC == nil {
			cfErr := C.cfish_Err_get_error()
			panic(clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error))
		}
		defer C.cfish_decref(unsafe.Pointer(retvalC))
		retval = vecToStringSlice(retvalC)
	})
	return retval, err
}