4040package  directory
4141
4242import  (
43+ 	"context" 
4344	"errors" 
4445
4546	"github.com/apple/foundationdb/bindings/go/src/fdb" 
@@ -79,7 +80,7 @@ type Directory interface {
7980	// recorded as the layer; if layer is specified and the directory already 
8081	// exists, it is compared against the layer specified when the directory was 
8182	// created, and an error is returned if they differ. 
82- 	CreateOrOpen (t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error )
83+ 	CreateOrOpen (ctx  context. Context ,  t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error )
8384
8485	// Open opens the directory specified by path (relative to this Directory), 
8586	// and returns the directory and its contents as a DirectorySubspace (or ErrDirNotExists 
@@ -89,15 +90,15 @@ type Directory interface {
8990	// If the byte slice layer is specified, it is compared against the layer 
9091	// specified when the directory was created, and an error is returned if 
9192	// they differ. 
92- 	Open (rt  fdb.ReadTransactor , path  []string , layer  []byte ) (DirectorySubspace , error )
93+ 	Open (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string , layer  []byte ) (DirectorySubspace , error )
9394
9495	// Create creates a directory specified by path (relative to this 
9596	// Directory), and returns the directory and its contents as a 
9697	// DirectorySubspace (or ErrDirAlreadyExists if the directory already exists). 
9798	// 
9899	// If the byte slice layer is specified, it is recorded as the layer and 
99100	// will be checked when opening the directory in the future. 
100- 	Create (t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error )
101+ 	Create (ctx  context. Context ,  t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error )
101102
102103	// CreatePrefix behaves like Create, but uses a manually specified byte 
103104	// slice prefix to physically store the contents of this directory, rather 
@@ -106,7 +107,7 @@ type Directory interface {
106107	// If this Directory was created in a root directory that does not allow 
107108	// manual prefixes, CreatePrefix will return an error. The default root 
108109	// directory does not allow manual prefixes. 
109- 	CreatePrefix (t  fdb.Transactor , path  []string , layer  []byte , prefix  []byte ) (DirectorySubspace , error )
110+ 	CreatePrefix (ctx  context. Context ,  t  fdb.Transactor , path  []string , layer  []byte , prefix  []byte ) (DirectorySubspace , error )
110111
111112	// Move moves the directory at oldPath to newPath (both relative to this 
112113	// Directory), and returns the directory (at its new location) and its 
@@ -116,7 +117,7 @@ type Directory interface {
116117	// 
117118	// There is no effect on the physical prefix of the given directory or on 
118119	// clients that already have the directory open. 
119- 	Move (t  fdb.Transactor , oldPath  []string , newPath  []string ) (DirectorySubspace , error )
120+ 	Move (ctx  context. Context ,  t  fdb.Transactor , oldPath  []string , newPath  []string ) (DirectorySubspace , error )
120121
121122	// MoveTo moves this directory to newAbsolutePath (relative to the root 
122123	// directory of this Directory), and returns the directory (at its new 
@@ -126,7 +127,7 @@ type Directory interface {
126127	// 
127128	// There is no effect on the physical prefix of the given directory or on 
128129	// clients that already have the directory open. 
129- 	MoveTo (t  fdb.Transactor , newAbsolutePath  []string ) (DirectorySubspace , error )
130+ 	MoveTo (ctx  context. Context ,  t  fdb.Transactor , newAbsolutePath  []string ) (DirectorySubspace , error )
130131
131132	// Remove removes the directory at path (relative to this Directory), its 
132133	// content, and all subdirectories. Remove returns true if a directory 
@@ -135,16 +136,16 @@ type Directory interface {
135136	// 
136137	// Note that clients that have already opened this directory might still 
137138	// insert data into its contents after removal. 
138- 	Remove (t  fdb.Transactor , path  []string ) (bool , error )
139+ 	Remove (ctx  context. Context ,  t  fdb.Transactor , path  []string ) (bool , error )
139140
140141	// Exists returns true if the directory at path (relative to this Directory) 
141142	// exists, and false otherwise. 
142- 	Exists (rt  fdb.ReadTransactor , path  []string ) (bool , error )
143+ 	Exists (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string ) (bool , error )
143144
144145	// List returns the names of the immediate subdirectories of the directory 
145146	// at path (relative to this Directory) as a slice of strings. Each string 
146147	// is the name of the last component of a subdirectory's path. 
147- 	List (rt  fdb.ReadTransactor , path  []string ) ([]string , error )
148+ 	List (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string ) ([]string , error )
148149
149150	// GetLayer returns the layer specified when this Directory was created. 
150151	GetLayer () []byte 
@@ -165,14 +166,14 @@ func stringsEqual(a, b []string) bool {
165166	return  true 
166167}
167168
168- func  moveTo (t  fdb.Transactor , dl  directoryLayer , path , newAbsolutePath  []string ) (DirectorySubspace , error ) {
169+ func  moveTo (ctx  context. Context ,  t  fdb.Transactor , dl  directoryLayer , path , newAbsolutePath  []string ) (DirectorySubspace , error ) {
169170	partition_len  :=  len (dl .path )
170171
171172	if  ! stringsEqual (newAbsolutePath [:partition_len ], dl .path ) {
172173		return  nil , errors .New ("cannot move between partitions" )
173174	}
174175
175- 	return  dl .Move (t , path [partition_len :], newAbsolutePath [partition_len :])
176+ 	return  dl .Move (ctx ,  t , path [partition_len :], newAbsolutePath [partition_len :])
176177}
177178
178179var  root  =  NewDirectoryLayer (subspace .FromBytes ([]byte {0xFE }), subspace .AllKeys (), false )
@@ -186,8 +187,8 @@ var root = NewDirectoryLayer(subspace.FromBytes([]byte{0xFE}), subspace.AllKeys(
186187// as the layer; if layer is specified and the directory already exists, it is 
187188// compared against the layer specified when the directory was created, and an 
188189// error is returned if they differ. 
189- func  CreateOrOpen (t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
190- 	return  root .CreateOrOpen (t , path , layer )
190+ func  CreateOrOpen (ctx  context. Context ,  t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
191+ 	return  root .CreateOrOpen (ctx ,  t , path , layer )
191192}
192193
193194// Open opens the directory specified by path (resolved relative to the default 
@@ -197,8 +198,8 @@ func CreateOrOpen(t fdb.Transactor, path []string, layer []byte) (DirectorySubsp
197198// If the byte slice layer is specified, it is compared against the layer 
198199// specified when the directory was created, and an error is returned if they 
199200// differ. 
200- func  Open (rt  fdb.ReadTransactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
201- 	return  root .Open (rt , path , layer )
201+ func  Open (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
202+ 	return  root .Open (ctx ,  rt , path , layer )
202203}
203204
204205// Create creates a directory specified by path (resolved relative to the 
@@ -207,8 +208,8 @@ func Open(rt fdb.ReadTransactor, path []string, layer []byte) (DirectorySubspace
207208// 
208209// If the byte slice layer is specified, it is recorded as the layer and will be 
209210// checked when opening the directory in the future. 
210- func  Create (t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
211- 	return  root .Create (t , path , layer )
211+ func  Create (ctx  context. Context ,  t  fdb.Transactor , path  []string , layer  []byte ) (DirectorySubspace , error ) {
212+ 	return  root .Create (ctx ,  t , path , layer )
212213}
213214
214215// Move moves the directory at oldPath to newPath (both resolved relative to the 
@@ -219,21 +220,21 @@ func Create(t fdb.Transactor, path []string, layer []byte) (DirectorySubspace, e
219220// 
220221// There is no effect on the physical prefix of the given directory or on 
221222// clients that already have the directory open. 
222- func  Move (t  fdb.Transactor , oldPath  []string , newPath  []string ) (DirectorySubspace , error ) {
223- 	return  root .Move (t , oldPath , newPath )
223+ func  Move (ctx  context. Context ,  t  fdb.Transactor , oldPath  []string , newPath  []string ) (DirectorySubspace , error ) {
224+ 	return  root .Move (ctx ,  t , oldPath , newPath )
224225}
225226
226227// Exists returns true if the directory at path (relative to the default root 
227228// directory) exists, and false otherwise. 
228- func  Exists (rt  fdb.ReadTransactor , path  []string ) (bool , error ) {
229- 	return  root .Exists (rt , path )
229+ func  Exists (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string ) (bool , error ) {
230+ 	return  root .Exists (ctx ,  rt , path )
230231}
231232
232233// List returns the names of the immediate subdirectories of the default root 
233234// directory as a slice of strings. Each string is the name of the last 
234235// component of a subdirectory's path. 
235- func  List (rt  fdb.ReadTransactor , path  []string ) ([]string , error ) {
236- 	return  root .List (rt , path )
236+ func  List (ctx  context. Context ,  rt  fdb.ReadTransactor , path  []string ) ([]string , error ) {
237+ 	return  root .List (ctx ,  rt , path )
237238}
238239
239240// Root returns the default root directory. Any attempt to move or remove the 
0 commit comments