Function to create symlinks atomically

This commit is contained in:
Kovid Goyal
2023-02-21 15:35:41 +05:30
parent fa45324d39
commit fbaaca1be9
5 changed files with 102 additions and 18 deletions

View File

@@ -3,16 +3,12 @@
package shm
import (
"crypto/rand"
"encoding/base32"
"encoding/binary"
"errors"
"fmt"
"io"
"io/fs"
not_rand "math/rand"
"os"
"strconv"
"strings"
"kitty/tools/cli"
@@ -48,15 +44,6 @@ func prefix_and_suffix(pattern string) (prefix, suffix string, err error) {
return prefix, suffix, nil
}
func next_random() string {
b := make([]byte, 8)
_, err := rand.Read(b)
if err != nil {
return strconv.FormatUint(uint64(not_rand.Uint32()), 16)
}
return base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(b)
}
type MMap interface {
Close() error
Unlink() error