Skip to content

Commit

Permalink
removed unused unix-only functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgeoisBear committed Apr 2, 2024
1 parent 112e3b3 commit e0c1580
Showing 1 changed file with 0 additions and 62 deletions.
62 changes: 0 additions & 62 deletions term_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package rasterm

import (
"errors"
"io"
"os"
"regexp"
"strconv"
"strings"
"sync"
"syscall"
"time"

"golang.org/x/term"
Expand Down Expand Up @@ -179,66 +177,6 @@ func RequestTermAttributes() (sAttrs []int, E error) {

var rxNumber = regexp.MustCompile(`\d+`)

func findPtyDevByStat(pStat *syscall.Stat_t) (string, error) {

for _, devDir := range []string{"/dev/pts", "/dev"} {

fd, E := os.Open(devDir)
if os.IsNotExist(E) {
continue
} else if E != nil {
return "", E
}
defer fd.Close()

for {

fis, e2 := fd.Readdir(256)
for _, fi := range fis {

if fi.IsDir() {
continue
}

if s, ok := fi.Sys().(*syscall.Stat_t); ok && (pStat.Dev == s.Dev) && (pStat.Rdev == s.Rdev) && (pStat.Ino == s.Ino) {
return devDir + "/" + fi.Name(), nil
}
}

if e2 == io.EOF {
break
}

if e2 != nil {
return "", e2
}
}
}

return "", os.ErrNotExist
}

func GetTtyPath(pF *os.File) (string, error) {

info, E := pF.Stat()
if E != nil {
return "", E
}

if sys, ok := info.Sys().(*syscall.Stat_t); ok {

if path, e := findPtyDevByStat(sys); e == nil {
return path, nil
} else if os.IsNotExist(e) {
return "", E_NON_TTY
} else {
return "", e
}
}

return "", nil
}

func lcaseEnv(k string) string {
return strings.ToLower(strings.TrimSpace(os.Getenv(k)))
}
Expand Down

0 comments on commit e0c1580

Please sign in to comment.