go-hep.org/x/hep@v0.38.1/xrootd/xrdfs/fs.go (about)

     1  // Copyright ©2018 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package xrdfs contains structures representing the XRootD-based filesystem.
     6  package xrdfs
     7  
     8  import (
     9  	"context"
    10  )
    11  
    12  // FileSystem implements access to a collection of named files over XRootD.
    13  type FileSystem interface {
    14  	// Dirlist returns the contents of a directory together with the stat information.
    15  	Dirlist(ctx context.Context, path string) ([]EntryStat, error)
    16  
    17  	// Open returns the file handle for a file together with the compression and the stat info.
    18  	Open(ctx context.Context, path string, mode OpenMode, options OpenOptions) (File, error)
    19  
    20  	// RemoveFile removes the file at path.
    21  	RemoveFile(ctx context.Context, path string) error
    22  
    23  	// Truncate changes the size of the named file.
    24  	Truncate(ctx context.Context, path string, size int64) error
    25  
    26  	// Stat returns the entry stat info for the given path.
    27  	Stat(ctx context.Context, path string) (EntryStat, error)
    28  
    29  	// VirtualStat returns the virtual filesystem stat info for the given path.
    30  	// Note that path needs not to be an existing filesystem object, it is used as a path prefix in order to
    31  	// filter out servers and partitions that could not be used to hold objects whose path starts
    32  	// with the specified path prefix.
    33  	VirtualStat(ctx context.Context, path string) (VirtualFSStat, error)
    34  
    35  	// Mkdir creates a new directory with the specified name and permission bits.
    36  	Mkdir(ctx context.Context, path string, perm OpenMode) error
    37  
    38  	// MkdirAll creates a directory named path, along with any necessary parents,
    39  	// and returns nil, or else returns an error.
    40  	// The permission bits perm are used for all directories that MkdirAll creates.
    41  	MkdirAll(ctx context.Context, path string, perm OpenMode) error
    42  
    43  	// RemoveDir removes a directory.
    44  	// The directory to be removed must be empty.
    45  	RemoveDir(ctx context.Context, path string) error
    46  
    47  	// RemoveAll removes path and any children it contains.
    48  	// It removes everything it can but returns the first error it encounters.
    49  	// If the path does not exist, RemoveAll returns nil (no error.)
    50  	RemoveAll(ctx context.Context, path string) error
    51  
    52  	// Rename renames (moves) oldpath to newpath.
    53  	Rename(ctx context.Context, oldpath, newpath string) error
    54  
    55  	// Chmod changes the permissions of the named file to perm.
    56  	Chmod(ctx context.Context, path string, mode OpenMode) error
    57  
    58  	// Statx obtains type information for one or more paths.
    59  	// Only a limited number of flags is meaningful such as StatIsExecutable, StatIsDir, StatIsOther, StatIsOffline.
    60  	Statx(ctx context.Context, paths []string) ([]StatFlags, error)
    61  }
    62  
    63  // OpenMode is the mode in which path is to be opened.
    64  // The mode is an "or`d" combination of ModeXyz flags.
    65  type OpenMode uint16
    66  
    67  const (
    68  	OpenModeOwnerRead    OpenMode = 0x100 // OpenModeOwnerRead indicates that owner has read access.
    69  	OpenModeOwnerWrite   OpenMode = 0x080 // OpenModeOwnerWrite indicates that owner has write access.
    70  	OpenModeOwnerExecute OpenMode = 0x040 // OpenModeOwnerExecute indicates that owner has execute access.
    71  
    72  	OpenModeGroupRead    OpenMode = 0x020 // OpenModeGroupRead indicates that group has read access.
    73  	OpenModeGroupWrite   OpenMode = 0x010 // OpenModeGroupWrite indicates that group has write access.
    74  	OpenModeGroupExecute OpenMode = 0x008 // OpenModeGroupExecute indicates that group has execute access.
    75  
    76  	OpenModeOtherRead    OpenMode = 0x004 // OpenModeOtherRead indicates that owner has read access.
    77  	OpenModeOtherWrite   OpenMode = 0x002 // OpenModeOtherWrite indicates that owner has write access.
    78  	OpenModeOtherExecute OpenMode = 0x001 // OpenModeOtherExecute indicates that owner has execute access.
    79  )
    80  
    81  // OpenOptions are the options to apply when path is opened.
    82  type OpenOptions uint16
    83  
    84  const (
    85  	// OpenOptionsCompress specifies that file is opened even when compressed.
    86  	OpenOptionsCompress OpenOptions = 1 << iota
    87  	// OpenOptionsDelete specifies that file is opened deleting any existing file.
    88  	OpenOptionsDelete
    89  	// OpenOptionsForce specifies that file is opened ignoring  file usage rules.
    90  	OpenOptionsForce
    91  	// OpenOptionsNew specifies that file is opened only if it does not already exist.
    92  	OpenOptionsNew
    93  	// OpenOptionsOpenRead specifies that file is opened only for reading.
    94  	OpenOptionsOpenRead
    95  	// OpenOptionsOpenUpdate specifies that file is opened only for reading and writing.
    96  	OpenOptionsOpenUpdate
    97  	// OpenOptionsAsync specifies that file is opened for asynchronous i/o.
    98  	OpenOptionsAsync
    99  	// OpenOptionsRefresh specifies that cached information on the file's location need to be updated.
   100  	OpenOptionsRefresh
   101  	// OpenOptionsMkPath specifies that directory path is created if it does not already exist.
   102  	OpenOptionsMkPath
   103  	// OpenOptionsOpenAppend specifies that file is opened only for appending.
   104  	OpenOptionsOpenAppend
   105  	// OpenOptionsReturnStatus specifies that file status information should be returned in the response.
   106  	OpenOptionsReturnStatus
   107  	// OpenOptionsReplica specifies that file is opened for replica creation.
   108  	OpenOptionsReplica
   109  	// OpenOptionsPOSC specifies that Persist On Successful Close (POSC) processing should be enabled.
   110  	OpenOptionsPOSC
   111  	// OpenOptionsNoWait specifies that file is opened only if it does not cause a wait.
   112  	OpenOptionsNoWait
   113  	// OpenOptionsSequentiallyIO specifies that file will be read or written sequentially.
   114  	OpenOptionsSequentiallyIO
   115  	// OpenOptionsNone specifies that file is opened without specific options.
   116  	OpenOptionsNone OpenOptions = 0
   117  )