v0.16.0 import PGN, delete games, two-layout web client
This commit is contained in:
1 parent
e1fa5242e3
commit
664cf9654e
34 files changed
+2007
-150
No files matched your search
@@ -0,0 +1,26 @@
|
||||
//go:build !js && !wasm
|
||||
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
const maxImportFile = 64 << 10
|
||||
|
||||
// readImportFile reads a PGN file for import.
|
||||
func readImportFile(path string) (string, error) {
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if info.Size() > maxImportFile {
|
||||
return "", fmt.Errorf("%s is larger than %d bytes", path, maxImportFile)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
Reference in new issue
Block a user