Esempio n. 1
0
func (fs *FS) OpenDir(dpath string) durablefs.Dir {
	return &Dir{
		conn:  fs.conn,
		zroot: fs.zroot,
		dpath: dpath,
		watch: zutil.InstallWatch(fs.conn, path.Join(fs.zroot, dpath)),
	}
}
Esempio n. 2
0
func makeDir(fs *FS, anchor string) (*Dir, error) {
	dir := &Dir{
		fs:     fs,
		anchor: anchor,
	}
	dir.watch = zutil.InstallWatch(fs.zookeeper, dir.zdir())
	// The semantics of AnchorFS pretend that all directories always exist,
	// which is not the case in Zookeeper. To make this work, we create the
	// directory on access.
	if err := zutil.CreateRecursive(dir.fs.zookeeper, dir.zdir(), zutil.PermitAll); err != nil {
		return nil, err
	}
	return dir, nil
}