Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.

2 downloads

network-computer/cmd/nc-host/files_unix.go
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/demo/network-computer.git
HTTPS
https://gitstable.com/git/demo/network-computer.git
SSH
ssh://git@gitstable.com:2222/demo/network-computer.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

GitStable demo README: say this is a copy and where the original is cde82c2 13 hours, 39 minutes ago History
files_unix.go · 845 bytes · 39 lines
1//go:build linux || darwin
2
3package main
4
5import (
6 "os"
7 "syscall"
8)
9
10func freeBytes(dir string) (int64, error) {
11 var st syscall.Statfs_t
12 if err := syscall.Statfs(dir, &st); err != nil {
13 return 0, err
14 }
15 return int64(st.Bavail) * int64(st.Bsize), nil
16}
17
18// chownLike gives a received file to whoever owns the directory it lands in
19// (the host runs as root; the file belongs to the desk user).
20func chownLike(path, dir string) {
21 if fi, err := os.Stat(dir); err == nil {
22 if st, ok := fi.Sys().(*syscall.Stat_t); ok {
23 os.Chown(path, int(st.Uid), int(st.Gid))
24 }
25 }
26}
27
28// ownerGroup is the group of whoever owns dir (the desk user).
29func ownerGroup(dir string) (int, bool) {
30 fi, err := os.Stat(dir)
31 if err != nil {
32 return 0, false
33 }
34 st, ok := fi.Sys().(*syscall.Stat_t)
35 if !ok {
36 return 0, false
37 }
38 return int(st.Gid), true
39}