Skip to content

Commit

Permalink
optimize HiddenFS.Create
Browse files Browse the repository at this point in the history
  • Loading branch information
jxsl13 committed Jul 15, 2024
1 parent 2753fba commit 35d6763
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions hiddenfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ func (fs *HiddenFS) isParentOfHidden(name string) (bool, error) {
// Create creates a file in the filesystem, returning the file and an
// error, if any happens.
func (s *HiddenFS) Create(name string) (File, error) {
hidden, err := s.isHidden(name)
if err != nil {
return nil, &os.PathError{Op: "create", Path: name, Err: wrapErrHiddenCheckFailed(err)}
}
if hidden {
return nil, &os.PathError{Op: "create", Path: name, Err: ErrHiddenPermission}
}
// OpenFile already does the hidden checks
f, err := s.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return nil, &os.PathError{Op: "create", Path: name, Err: err}
Expand Down

0 comments on commit 35d6763

Please sign in to comment.