package
0.0.0-20161202185726-98eddf990150
Repository: https://github.com/hellbutcher/go-mmstruct.git
Documentation: pkg.go.dev
# README
go-mmstruct / mmf 
working with memory mapped files in golang.
Installation
Go and get it...
$ go get github.com/HellButcher/go-mmstruct/mmf
Usage
Creating a file:
package main
import (
"github.com/HellButcher/go-mmstruct/mmf"
)
func main() {
mf, err := mmf.CreateMappedFile("aNewFile.bin", 4096)
if err != nil {
// ...
}
defer mf.Close()
// do something in the mapped memory area
data := mf.Bytes()
data[1337] = 42 // writing
foo := data[666] // reading
}
Opening a file:
package main
import (
"github.com/HellButcher/go-mmstruct/mmf"
)
func main() {
mf, err := mmf.OpenMappedFile("anExistingFile.bin")
if err != nil {
// ...
}
defer mf.Close()
// do something in the mapped memory area
data := mf.Bytes()
data[666] = 42 // writing
foo := data[1337] // reading
}
The MappedFile
object can also be used as a Reader
or
Writer
(and some other interfaces).
# Functions
CreateBlockFile creates a new block-file at the given filename with the DefaultBlocksize.
CreateBlockFileInMapper creates a new block-file in the given Mapper with the DefaultBlocksize.
CreateBlockFileInMapperWithSize creates a new block-file in the given Mapper with the given blocksize.
CreateBlockFileWithSize creates a new block-file at the given filename with the given blocksize.
CreateMappedFile creates a new file (or replaces an existing one) with the given initial size.
OpenBlockFile opens an existing block-file that is given as filename.
OpenBlockFileFromMapper opens an existing block-file by providig a Mapper.
OpenMappedFile opens an existing file and maps it to memory.
# Constants
the first 4 byte of a block-file.
No description provided by the author
The default block size that is used by CreateBlockFile and CreateBlockFileInMapper.
seek relative to the current offset.
seek relative to the end.
seek relative to the origin of the file.
# Structs
No description provided by the author
MappedFile is a struct that defines an open memory mapped file.
# Interfaces
Mapper is an interface that wraps basic methods for accessing memory mapped files.