// Copyright 2026 Rose Hogenson // // This file is part of ccp. // // Ccp is free software: you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the Free Software // Foundation, either version 3 of the License, or (at your option) any later // version. // // Ccp is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // ccp. If not, see . // Package osfs implements [wfs.FS] backed by the local filesystem. package osfs import ( "io" "io/fs" "os" "roseh.moe/cmd/ccp/internal/wfs" ) var ( _ wfs.FS = FS{} _ wfs.MkdirModeFS = FS{} _ wfs.ReadLinkFS = FS{} _ fs.StatFS = FS{} ) // An FS is a [wfs.FS] backed by the local filesystem. type FS struct{} func (FS) Open(name string) (fs.File, error) { return os.Open(name) } func (FS) Stat(name string) (fs.FileInfo, error) { return os.Stat(name) } func (FS) Lstat(name string) (fs.FileInfo, error) { return os.Lstat(name) } func (FS) ReadLink(name string) (string, error) { return os.Readlink(name) } func (FS) Create(name string, perm fs.FileMode) (io.WriteCloser, error) { return os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm) } func (FS) Remove(name string) error { return os.Remove(name) } func (FS) Mkdir(name string) error { return os.Mkdir(name, 0700) } func (FS) MkdirMode(name string, mode fs.FileMode) error { return os.Mkdir(name, mode) } func (FS) Symlink(oldname, newname string) error { return os.Symlink(oldname, newname) } func (FS) Chmod(name string, mode fs.FileMode) error { return os.Chmod(name, mode) }