chore: import official kitty sources from upstream
Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
This commit is contained in:
commit
7e7d249099
1134 files changed
+433629
No files matched your search
@@ -0,0 +1,42 @@
|
||||
//go:build !linux
|
||||
|
||||
// License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
func CreateAnonymousTemp(dir string, perms ...fs.FileMode) (*os.File, error) {
|
||||
var perm fs.FileMode = unix.S_IREAD | unix.S_IWRITE
|
||||
default_perm := perm
|
||||
if len(perms) > 0 {
|
||||
perm = perms[0]
|
||||
}
|
||||
|
||||
f, err := os.CreateTemp(dir, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if perm != default_perm {
|
||||
err = f.Chmod(perm & fs.ModePerm)
|
||||
if err != nil {
|
||||
os.Remove(f.Name())
|
||||
f.Close()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = os.Remove(f.Name())
|
||||
if err != nil {
|
||||
f.Close()
|
||||
return nil, err
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
Reference in new issue
Block a user