Sync updates with elichika

As of https://github.com/YumeMichi/elichika/commit/81a78e964dcdb8bb2d123237f966f95e7fba190e

Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
2023-07-20 00:21:22 +08:00
parent 4146728579
commit 81e97cf997
43 changed files with 40727 additions and 35491 deletions
+11
View File
@@ -7,15 +7,23 @@ import (
"encoding/hex"
"math/rand"
"os"
"sync"
"time"
)
var (
rwMutex sync.RWMutex
)
func PathExists(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}
func ReadAllText(path string) string {
rwMutex.RLock()
defer rwMutex.RUnlock()
b, err := os.ReadFile(path)
if err != nil {
return ""
@@ -24,6 +32,9 @@ func ReadAllText(path string) string {
}
func WriteAllText(path, text string) {
rwMutex.Lock()
defer rwMutex.Unlock()
_ = os.WriteFile(path, []byte(text), 0644)
}