read support for length and offset

This commit is contained in:
Chapuis Bertil
2015-08-15 10:06:10 +02:00
parent 71163e75d1
commit 59621ca2d6
6 changed files with 321 additions and 62 deletions

View File

@@ -1,6 +1,11 @@
package main
import ()
import (
"os"
"path/filepath"
"github.com/restic/restic/backend"
)
// A Context specifies the root directory where all repositories are stored
type Context struct {
@@ -8,10 +13,18 @@ type Context struct {
}
func NewContext(path string) Context {
return Context{path}
return Context{filepath.Clean(path)}
}
// Creates the file structure of the Context
func (c *Context) Init() {
func (c *Context) Init() error {
if _, err := os.Stat(c.path); err != nil {
return os.MkdirAll(c.path, backend.Modes.Dir)
}
return nil
}
func (c *Context) Repository(name string) (Repository, error) {
name, err := ParseRepositoryName(name)
return Repository{filepath.Join(c.path, name)}, err
}