mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Merge pull request #3273 from JoeKar/fix/save-atomically
save: Perform write process safe
This commit is contained in:
@@ -6,7 +6,6 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -34,7 +33,7 @@ func main() {
|
||||
if len(os.Args) > 1 {
|
||||
os.Chdir(os.Args[1])
|
||||
}
|
||||
files, _ := ioutil.ReadDir(".")
|
||||
files, _ := os.ReadDir(".")
|
||||
for _, f := range files {
|
||||
fname := f.Name()
|
||||
if strings.HasSuffix(fname, ".yaml") {
|
||||
@@ -46,7 +45,7 @@ func main() {
|
||||
func convert(name string) {
|
||||
filename := name + ".yaml"
|
||||
var hdr HeaderYaml
|
||||
source, err := ioutil.ReadFile(filename)
|
||||
source, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -68,7 +67,7 @@ func encode(name string, c HeaderYaml) {
|
||||
|
||||
func decode(name string) Header {
|
||||
start := time.Now()
|
||||
data, _ := ioutil.ReadFile(name + ".hdr")
|
||||
data, _ := os.ReadFile(name + ".hdr")
|
||||
strs := bytes.Split(data, []byte{'\n'})
|
||||
var hdr Header
|
||||
hdr.FileType = string(strs[0])
|
||||
|
||||
@@ -4,7 +4,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -161,6 +160,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
data, _ := ioutil.ReadFile(os.Args[1])
|
||||
data, _ := os.ReadFile(os.Args[1])
|
||||
fmt.Print(generateFile(parseFile(string(data), os.Args[1])))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user