예제 #1
0
// CreateDirectory creates a sub-Directory of the provided Directory
func CreateDirectory(d dir.Directory, name string) *Directory {
	subdir := &Directory{
		uuid: uuid.NewV4(),
		name: name,
	}
	if d != nil {
		subdir.root = d.Root()
		subdir.parent = d
		err := d.AttachDirectory(subdir)
		if err != nil {
			// TODO: decide how to handle err != nil; we would like CreateDirectory to be chainable, hence not returning err
			return nil
		}
	} else {
		subdir.root = subdir
	}
	return subdir
}