// NewFs constructs an Fs from the path.
//
// The returned Fs is the actual Fs, referenced by remote in the config
NewFs constructs an Fs from the path.

The returned Fs is the actual Fs, referenced by remote in the config
// NewFs constructs an Fs from the path . // // The returned Fs is the actual Fs referenced by remote in the config
func NewFs(name, root string, m configmap.Mapper) (fs.Fs, error) {
	opt := new(Options)
	err := configstruct.Set(m, opt)
	if err != nil {
		return nil, err
	}
	if len(opt.Remotes) == 0 {
		return nil, errors.New("union can't point to an empty remote - check the value of the remotes setting")
	}
	if len(opt.Remotes) == 1 {
		return nil, errors.New("union can't point to a single remote - check the value of the remotes setting")
	}
	for _, remote := range opt.Remotes {
		if strings.HasPrefix(remote, name+":") {
			return nil, errors.New("can't point union remote at itself - check the value of the remote setting")
		}
	}
	var remotes []fs.Fs
	for i := range opt.Remotes {
		var remote = opt.Remotes[len(opt.Remotes)-i-1]
		_, configName, fsPath, err := fs.ParseRemote(remote)
		if err != nil {
			return nil, err
		}
		var rootString = path.Join(fsPath, filepath.ToSlash(root))
		if configName != "local" {
			rootString = configName + ":" + rootString
		}
		myFs, err := fs.NewFs(rootString)
		if err != nil {
			if err == fs.ErrorIsFile {
				return myFs, err
			}
			return nil, err
		}
		remotes = append(remotes, myFs)
	}
	for i, j := 0, len(remotes)-1; i < j; i, j = i+1, j-1 {
		remotes[i], remotes[j] = remotes[j], remotes[i]
	}
	f := &Fs{
		name:    name,
		root:    root,
		opt:     *opt,
		remotes: remotes,
	}
	var features = (&fs.Features{
		CaseInsensitive:         true,
		DuplicateFiles:          false,
		ReadMimeType:            true,
		WriteMimeType:           true,
		CanHaveEmptyDirectories: true,
		BucketBased:             true,
	}).Fill(f)
	for _, remote := range f.remotes {
		features = features.Mask(remote)
	}
	f.features = features
	return f, nil
}
func NewFs ( name , root string , m configmap . Mapper ) ( fs . Fs , error ) { opt := new ( Options ) err := configstruct . Set ( m , opt ) if err != nil { return nil , err } if len ( opt . Remotes ) == 0 { return nil , errors . New ( " " ) } if len ( opt . Remotes ) == 1 { return nil , errors . New ( " " ) } for _ , remote := range opt . Remotes { if strings . HasPrefix ( remote , name + " " ) { return nil , errors . New ( " " ) } } var remotes [ ] fs . Fs for i := range opt . Remotes { var remote = opt . Remotes [ len ( opt . Remotes ) - i - 1 ] _ , configName , fsPath , err := fs . ParseRemote ( remote ) if err != nil { return nil , err } var rootString = path . Join ( fsPath , filepath . ToSlash ( root ) ) if configName != " " { rootString = configName + " " + rootString } myFs , err := fs . NewFs ( rootString ) if err != nil { if err == fs . ErrorIsFile { return myFs , err } return nil , err } remotes = append ( remotes , myFs ) } for i , j := 0 , len ( remotes ) - 1 ; i < j ; i , j = i + 1 , j - 1 { remotes [ i ] , remotes [ j ] = remotes [ j ] , remotes [ i ] } f := & Fs { name : name , root : root , opt : * opt , remotes : remotes , } var features = ( & fs . Features { CaseInsensitive : true , DuplicateFiles : false , ReadMimeType : true , WriteMimeType : true , CanHaveEmptyDirectories : true , BucketBased : true , } ) . Fill ( f ) for _ , remote := range f . remotes { features = features . Mask ( remote ) } f . features = features return f , nil }
NewFs constructs an Fs from the path.
NewFs constructs an Fs from the path .
// Parse config into Options struct // Last remote first so we return the correct (last) matching fs in case of fs.ErrorIsFile // Reverse the remotes again so they are in the order as before