github.com/aarzilli/tools@v0.0.0-20151123112009-0d27094f75e0/os/fsi/dsfs/20_types.go (about)

     1  package dsfs
     2  
     3  import (
     4  	"os"
     5  	"sync"
     6  	"time"
     7  
     8  	"golang.org/x/net/context"
     9  	ds "google.golang.org/appengine/datastore"
    10  )
    11  
    12  // Filesystem
    13  type dsFileSys struct {
    14  	// w http.ResponseWriter `datastore:"-" json:"-"`
    15  	// r *http.Request       `datastore:"-" json:"-"`
    16  	c context.Context `datastore:"-" json:"-"`
    17  
    18  	mount string // name of mount point, for remount
    19  
    20  	dirsorter  func([]os.FileInfo)
    21  	filesorter func([]DsFile)
    22  }
    23  
    24  // The distinction between AeDir and AeFile
    25  // brings clarity into the low-level implementation.
    26  // And into the google datastore overlay architecture.
    27  //
    28  // However, AeDir needs many redundant methods,
    29  // since it must be convertable into fsi.File in Open()
    30  
    31  // Upper case field names sadly
    32  // inevitable, for ae datastore :(
    33  type DsDir struct {
    34  	fSys *dsFileSys `datastore:"-" json:"-"` // Reference to root
    35  	Key  *ds.Key    `datastore:"-" json:"-"` // throw out? Can be constructed from Dir+BName
    36  
    37  	Dir      string
    38  	BName    string      // BaseName - distinct from os.FileInfo method Name()
    39  	isDir    bool        // distinct from os.FileInfo method IsDir()
    40  	MModTime time.Time   `datastore:"ModTime" json:"ModTime"`
    41  	MMode    os.FileMode `datastore:"-" json:"-"` // SaveProperty must be implemented
    42  
    43  	memDirFetchPos int // read position for f.Readdir
    44  }
    45  
    46  // Upper case field names sadly
    47  // inevitable, for ae datastore :(
    48  type DsFile struct {
    49  	fSys *dsFileSys `datastore:"-" json:"-"` // Reference to root
    50  	Key  *ds.Key    `datastore:"-" json:"-"` // throw out? Can be constructed from Dir+BName.
    51  
    52  	Dir      string
    53  	BName    string      // BaseName - distinct from os.FileInfo method Name()
    54  	isDir    bool        // distinct from os.FileInfo method IsDir()
    55  	MModTime time.Time   `datastore:"ModTime" json:"ModTime"`
    56  	MMode    os.FileMode `datastore:"-" json:"-"` // SaveProperty must be implemented
    57  
    58  	Data []byte `datastore:"Data" json:"Data"`
    59  	sync.Mutex
    60  	at     int64
    61  	closed bool // default open
    62  
    63  	memDirFetchPos int // read position for f.Readdir
    64  
    65  }