Files
llgo/internal/lib/_io/fs/fs.go
2024-07-11 18:20:12 +08:00

63 lines
1.9 KiB
Go

/*
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fs
// llgo:skipall
import (
_ "unsafe"
"github.com/goplus/llgo/internal/lib/syscall"
)
var (
ErrInvalid = syscall.ErrInvalid
ErrPermission = syscall.ErrPermission
ErrExist = syscall.ErrExist
ErrNotExist = syscall.ErrNotExist
ErrClosed = syscall.ErrClosed
)
// -----------------------------------------------------------------------------
// A FileMode represents a file's mode and permission bits.
// The bits have the same definition on all systems, so that
// information about files can be moved from one system
// to another portably. Not all bits apply to all systems.
// The only required bit is [ModeDir] for directories.
type FileMode uint32
// -----------------------------------------------------------------------------
// PathError records an error and the operation and file path that caused it.
type PathError struct {
Op string
Path string
Err error
}
func (e *PathError) Error() string { return e.Op + " " + e.Path + ": " + e.Err.Error() }
func (e *PathError) Unwrap() error { return e.Err }
// Timeout reports whether this error represents a timeout.
func (e *PathError) Timeout() bool {
t, ok := e.Err.(interface{ Timeout() bool })
return ok && t.Timeout()
}
// -----------------------------------------------------------------------------