Skip to content
go-libfossil Artifact [6252796e48]
Login

Artifact [6252796e48]

Artifact 6252796e4882ac97071911728b71bd70e11f532c3b9ac5a286849557ffa146bb:


//go:build unix

package simio

import (
	"os"
	"syscall"
)

// wOK is access(2)'s W_OK.
const wOK = 0x2

// CheckWritable reports, with access(2), whether this process may write
// path: a file's content, or a directory's entries. It is not part of
// Storage, since not every storage has permissions; callers that need it
// check for it.
func (OSStorage) CheckWritable(path string) error {
	if err := syscall.Access(path, wOK); err != nil {
		return &os.PathError{Op: "access", Path: path, Err: err}
	}
	return nil
}