代码拉取完成,页面将自动刷新
// replication-manager - Replication Manager Monitoring and CLI for MariaDB
// Authors: Guillaume Lefranc <[email protected]>
// Stephane Varoqui <[email protected]>
// This source code is licensed under the GNU General Public License, version 3.
// Redistribution/Reuse of this code is permitted under the GNU v3 license, as
// an additional term, ALL code must carry the original Author(s) credit in comment form.
// See LICENSE in this directory for the integral text.
package main
import (
"encoding/binary"
"os"
)
type stateFile struct {
Handle *os.File
Name string
Count int32
Timestamp int64
}
func newStateFile(name string) *stateFile {
sf := new(stateFile)
sf.Name = name
return sf
}
func (sf *stateFile) access() error {
var err error
sf.Handle, err = os.OpenFile(sf.Name, os.O_RDWR|os.O_CREATE, 0666)
if err != nil {
return err
}
return nil
}
func (sf *stateFile) write() error {
err := sf.Handle.Truncate(0)
sf.Handle.Seek(0, 0)
if err != nil {
return err
}
err = binary.Write(sf.Handle, binary.LittleEndian, sf.Count)
if err != nil {
return err
}
err = binary.Write(sf.Handle, binary.LittleEndian, sf.Timestamp)
if err != nil {
return err
}
return nil
}
func (sf *stateFile) read() error {
sf.Handle.Seek(0, 0)
err := binary.Read(sf.Handle, binary.LittleEndian, &sf.Count)
if err != nil {
return err
}
err = binary.Read(sf.Handle, binary.LittleEndian, &sf.Timestamp)
if err != nil {
return err
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。