當前位置: 首頁>>代碼示例>>Golang>>正文


Golang file2.BlockDevice類代碼示例

本文整理匯總了Golang中file-structures/block/file2.BlockDevice的典型用法代碼示例。如果您正苦於以下問題:Golang BlockDevice類的具體用法?Golang BlockDevice怎麽用?Golang BlockDevice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BlockDevice類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: new_list_block

func new_list_block(file file.BlockDevice, new_list bool) (self *list_block, err error) {
	key, err := file.Allocate()
	if err != nil {
		return nil, err
	}
	bytes := make(bs.ByteSlice, file.BlockSize())
	data := bytes[LIST_HEADER_LEN:]
	var header *list_header
	if new_list {
		header = &list_header{
			next:         0,
			head:         key,
			tail:         key,
			insert_point: key + LIST_HEADER_LEN,
			block_count:  1,
			list_length:  0,
		}
	} else {
		header = &list_header{next: 0}
	}
	self = &list_block{
		file:   file,
		key:    key,
		bytes:  bytes,
		data:   data,
		header: header,
	}
	return self, nil
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:29,代碼來源:list.go

示例2: allocBlock

func allocBlock(file file.BlockDevice) (blk *block, err error) {
	key, err := file.Allocate()
	if err != nil {
		return nil, err
	}
	size := file.BlockSize()
	bytes := make(bs.ByteSlice, size)
	return load_block(key, bytes), nil
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:9,代碼來源:block.go

示例3: readBlock

func readBlock(file file.BlockDevice, key int64) (blk *block, err error) {
	bytes, err := file.ReadBlock(key)
	if err != nil {
		return nil, err
	}
	return load_block(key, bytes), err
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:7,代碼來源:block.go

示例4: allocBlock

func allocBlock(file file.BlockDevice) (blk *block, err error) {
	key, err := file.Allocate()
	if err != nil {
		return nil, err
	}
	size := file.BlockSize()
	offset := size - METADATASIZE
	bytes := make(bs.ByteSlice, size)
	blk = &block{
		key:      key,
		block:    bytes,
		data:     bytes[:offset],
		metadata: bytes[offset:],
	}
	// fmt.Println("allocated", key)
	return blk, nil
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:17,代碼來源:varchar.go

示例5: load_list_block

func load_list_block(file file.BlockDevice, key int64) (self *list_block, err error) {
	bytes, err := file.ReadBlock(key)
	if err != nil {
		return nil, err
	}
	data := bytes[LIST_HEADER_LEN:]
	header := load_list_header(bytes)
	self = &list_block{
		file:   file,
		key:    key,
		bytes:  bytes,
		data:   data,
		header: header,
	}
	return self, nil
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:16,代碼來源:list.go

示例6: WriteBlock

func (self *block) WriteBlock(file file.BlockDevice) error {
	return file.WriteBlock(self.key, self.block)
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:3,代碼來源:block.go

示例7: datasize

func datasize(file file.BlockDevice) int64 {
	return int64(file.BlockSize()) - METADATASIZE
}
開發者ID:timtadh,項目名稱:file-structures,代碼行數:3,代碼來源:varchar.go


注:本文中的file-structures/block/file2.BlockDevice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。