You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DateKeys/cmd/datekeys/term_unix.go

21 lines
518 B

Format 3, step 5: the CLI datekeys encrypt writes format 3 and datekeys decrypt writes its files to a new folder, with the presentation of spec 29.7. - encrypt: -in is repeatable and takes files and folders; a folder gives its name as the first segment, as a browser does, and is walked with Lstat, following no link, taking regular files only. .DS_Store, Thumbs.db, desktop.ini, ._* and __MACOSX are left out of folders, and each one left out is reported (62.1 rule 15). New -comment, -author and -no-mtime; the mtimes are kept by default (rule 16). A capsule may hold a comment alone. The copy of a pipe to a temporary file goes, as only regular files are taken. - decrypt: the prelude decides. Format 3 claims -out with os.Mkdir, only when there are files, stages the tree in -out/.datekeys-* through an os.Root with O_EXCL and mode 0600, sets the mtimes, and moves each entry of the first level into place at step 18; any failure removes the folder (spec 56). Formats 1 and 2 still write a file. - The presentation goes to stdout: the verdicts, the declared author and the comment box with their labels, the paths, and the verdicts again. Every line of the creator goes in pieces of at most W - 3 columns behind the prefix, counting 2 for anything but printable ASCII, with its TABs expanded to multiples of 8; W is the width of the terminal, asked with syscall on Unix and Windows, or 80. Risky names get a warning: shortcuts, desktop.ini, .git, programs and a leading dash, compared by their key of R7. - Encrypt no longer runs in the CLI: only the test data generators set TestVectors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 week ago
//go:build linux || darwin || freebsd || netbsd || openbsd || dragonfly
package main
import (
"os"
"syscall"
"unsafe"
)
// termWidth returns the width of the terminal f, and false when f is not a
// terminal: TIOCGWINSZ fails on anything else.
func termWidth(f *os.File) (int, bool) {
var ws struct{ rows, cols, x, y uint16 }
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&ws)))
if errno != 0 {
return 0, false
}
return int(ws.cols), true
}

Powered by TurnKey Linux.