本文整理汇总了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;未经允许,请勿转载。 |
请发表评论