示例#1
0
文件: vsi.go 项目: kikht/gdal
// Create memory "file" from a buffer.
//
// A virtual memory file is created from the passed buffer with the indicated filename. Under normal conditions the filename would need to be absolute and within the /vsimem/ portion of the filesystem.
//
// The buffer remains the responsibility of the caller, and should not go out of scope as long as it might be accessed as a file. In no circumstances does this function take a copy of the data contents.
func VSIFileFromMemBuffer(filename string, data []byte) VSILFile {
	pszFilename := C.CString(filename)
	defer C.free(unsafe.Pointer(pszFilename))

	fp := C.VSIFileFromMemBuffer(pszFilename, (*C.GByte)(&data[0]), C.vsi_l_offset(len(data)), C.FALSE)
	return VSILFile(fp)
}
示例#2
0
文件: vsi.go 项目: kikht/gdal
// Seek to requested offset.
//
// Seek to the desired offset (nOffset) in the indicated file.
//
// This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.
//
// Analog of the POSIX fseek() call.
//
// Parameters:
//	fp 	file handle opened with VSIFOpenL().
//	offset 	offset in bytes.
//	whence 	one of SEEK_SET, SEEK_CUR or SEEK_END.
//
// Returns:
//	True on success or false on failure.
func VSIFSeekL(fp VSILFile, offset, whence int) bool {
	err := C.VSIFSeekL((*C.VSILFILE)(fp), C.vsi_l_offset(offset), C.int(whence))
	return err == 0
}
示例#3
0
文件: vsi.go 项目: kikht/gdal
// Truncate/expand the file to the specified size.
//
// This method goes through the VSIFileHandler virtualization and may work on unusual filesystems such as in memory.
//
// Analog of the POSIX ftruncate() call.
//
// Parameters:
//	fp 	file handle opened with VSIFOpenL().
//	newSize 	new size in bytes.
//
// Returns:
//	True on success or false on error.
func VSIFTruncateL(fp VSILFile, newSize int) bool {
	err := C.VSIFTruncateL((*C.VSILFILE)(fp), C.vsi_l_offset(newSize))
	return err == 0
}