[ARVADOS] created: 0788c2724ccf317932c5368f60ba709ab289b202

Git user git at public.curoverse.com
Wed Jun 7 17:36:53 EDT 2017


        at  0788c2724ccf317932c5368f60ba709ab289b202 (commit)


commit 0788c2724ccf317932c5368f60ba709ab289b202
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Jun 7 17:36:08 2017 -0400

    8784: Add (*Collection)FileSystem().
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/sdk/go/arvados/collection_fs.go b/sdk/go/arvados/collection_fs.go
new file mode 100644
index 0000000..867323b
--- /dev/null
+++ b/sdk/go/arvados/collection_fs.go
@@ -0,0 +1,84 @@
+package arvados
+
+import (
+	"net/http"
+	"os"
+	"path"
+	"time"
+
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/keepclient"
+)
+
+type collectionFS struct {
+	collection *Collection
+	client     *Client
+}
+
+type collectionFile struct {
+	keepclient.CollectionReader
+	collection *Collection
+	name       string
+}
+
+func (cf *collectionFile) Readdir(count int) ([]os.FileInfo, error) {
+	return []os.FileInfo{}, nil
+}
+
+func (cf *collectionFile) Stat() (os.FileInfo, error) {
+	return cf, nil
+}
+
+// Name implements os.FileInfo
+func (cf *collectionFile) Name() string {
+	return cf.name
+}
+
+// Size implements os.FileInfo
+func (cf *collectionFile) Size() int64 {
+	return int64(cf.CollectionReader.Len())
+}
+
+// Mode implements os.FileInfo
+func (cf *collectionFile) Mode() os.FileMode {
+	return 0444
+}
+
+// ModTime implements os.FileInfo
+func (cf *collectionFile) ModTime() time.Time {
+	if cf.collection.ModifiedAt == nil {
+		return time.Now()
+	}
+	return cf.modtime
+}
+
+// IsDir implements os.FileInfo
+func (cf *collectionFile) IsDir() bool {
+	return false
+}
+
+// Sys implements os.FileInfo
+func (cf *collectionFile) Sys() interface{} {
+	return nil
+}
+
+func (c *Collection) FileSystem(client *Client) http.FileSystem {
+	return &collectionFS{
+		collection: c,
+		client:     client,
+	}
+}
+
+func (c *collectionFS) Open(name string) (http.File, error) {
+	kc := keepclient.New(arvadosclient.New(c.client))
+	m := manifest.Manifest{Text: c.collection.ManifestText}
+	reader, err := kc.ManifestFileReader(m, name)
+	if err != nil {
+		return nil, err
+	}
+	return &collectionFile{
+		CollectionReader: reader,
+		collection:       c,
+		name:             path.Base(name),
+	}
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list