mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
More work on porting the SSH kitten
This commit is contained in:
@@ -4,7 +4,7 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"compress/bzip2"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -33,11 +33,14 @@ func ReadAll(r io.Reader, expected_size int) ([]byte, error) {
|
||||
func ReadCompressedEmbeddedData(raw string) []byte {
|
||||
compressed := UnsafeStringToBytes(raw)
|
||||
uncompressed_size := binary.LittleEndian.Uint32(compressed)
|
||||
r, _ := zlib.NewReader(bytes.NewReader(compressed[4:]))
|
||||
defer r.Close()
|
||||
r := bzip2.NewReader(bytes.NewReader(compressed[4:]))
|
||||
ans, err := ReadAll(r, int(uncompressed_size))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func ReaderForCompressedEmbeddedData(raw string) io.Reader {
|
||||
return bzip2.NewReader(bytes.NewReader(UnsafeStringToBytes(raw)[4:]))
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ var CacheDir = (&Once[string]{Run: func() (cache_dir string) {
|
||||
}}).Get
|
||||
|
||||
func macos_user_cache_dir() string {
|
||||
// Sadly Go does not provide confstr() so we use this hack. We could
|
||||
// Sadly Go does not provide confstr() so we use this hack.
|
||||
// Note that given a user generateduid and uid we can derive this by using
|
||||
// the algorithm at https://github.com/ydkhatri/MacForensics/blob/master/darwin_path_generator.py
|
||||
// but I cant find a good way to get the generateduid. Requires calling dscl in which case we might as well call getconf
|
||||
|
||||
Reference in New Issue
Block a user