mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 02:57:19 +03:00
MMap.Name() should return the SHM name not the full filesystem path
This commit is contained in:
parent
6ace082bc2
commit
2d1a2c30bf
@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -51,7 +52,8 @@ type MMap interface {
|
||||
Unlink() error
|
||||
Slice() []byte
|
||||
Name() string
|
||||
IsFilesystemBacked() bool
|
||||
IsFileSystemBacked() bool
|
||||
FileSystemName() string
|
||||
}
|
||||
|
||||
type AccessFlags int
|
||||
@ -107,6 +109,10 @@ func file_mmap(f *os.File, size uint64, access AccessFlags, truncate bool) (MMap
|
||||
}
|
||||
|
||||
func (self *file_based_mmap) Name() string {
|
||||
return filepath.Base(self.f.Name())
|
||||
}
|
||||
|
||||
func (self *file_based_mmap) FileSystemName() string {
|
||||
return self.f.Name()
|
||||
}
|
||||
|
||||
@ -131,7 +137,7 @@ func (self *file_based_mmap) Unlink() (err error) {
|
||||
return os.Remove(self.f.Name())
|
||||
}
|
||||
|
||||
func (self *file_based_mmap) IsFilesystemBacked() bool { return true }
|
||||
func (self *file_based_mmap) IsFileSystemBacked() bool { return true }
|
||||
|
||||
func CreateTemp(pattern string, size uint64) (MMap, error) {
|
||||
return create_temp(pattern, size)
|
||||
|
@ -108,7 +108,8 @@ func (self *syscall_based_mmap) Unlink() (err error) {
|
||||
return shm_unlink(self.Name())
|
||||
}
|
||||
|
||||
func (self *syscall_based_mmap) IsFilesystemBacked() bool { return false }
|
||||
func (self *syscall_based_mmap) IsFileSystemBacked() bool { return false }
|
||||
func (self *syscall_based_mmap) FileSystemName() string { return "" }
|
||||
|
||||
func create_temp(pattern string, size uint64) (ans MMap, err error) {
|
||||
var prefix, suffix string
|
||||
|
@ -48,8 +48,8 @@ func TestSHM(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatalf("Unlinking failed could re-open the SHM data. Data equal: %v Data length: %d", reflect.DeepEqual(g.Slice(), data), len(g.Slice()))
|
||||
}
|
||||
if mm.IsFilesystemBacked() {
|
||||
_, err = os.Stat(mm.Name())
|
||||
if mm.IsFileSystemBacked() {
|
||||
_, err = os.Stat(mm.FileSystemName())
|
||||
if !errors.Is(err, fs.ErrNotExist) {
|
||||
t.Fatalf("Unlinking %s did not work", mm.Name())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user