// TestFsMkdirRmdirSubdir tests making and removing a sub directory func TestFsMkdirRmdirSubdir(t *testing.T) { skipIfNotOk(t) dir := "dir/subdir" err := fs.Mkdir(remote, dir) require.NoError(t, err) fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir", "dir/subdir"}, fs.Config.ModifyWindow) err = fs.Rmdir(remote, dir) require.NoError(t, err) fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{"dir"}, fs.Config.ModifyWindow) err = fs.Rmdir(remote, "dir") require.NoError(t, err) fstest.CheckListingWithPrecision(t, remote, []fstest.Item{}, []string{}, fs.Config.ModifyWindow) }
Make the path if it doesn't already exist`, Run: func(fdst, fsrc fs.Fs) error { return fs.Mkdir(fdst) }, MinArgs: 1, MaxArgs: 1, Retry: true, }, { Name: "rmdir", ArgsHelp: "remote:path", Help: ` Remove the path. Note that you can't remove a path with objects in it, use purge for that.`, Run: func(fdst, fsrc fs.Fs) error { return fs.Rmdir(fdst) }, MinArgs: 1, MaxArgs: 1, Retry: true, }, { Name: "purge", ArgsHelp: "remote:path", Help: ` Remove the path and all of its contents.`, Run: func(fdst, fsrc fs.Fs) error { return fs.Purge(fdst) }, MinArgs: 1, MaxArgs: 1,
// TestRmdir tests Rmdir works func TestRmdir(t *testing.T, remote fs.Fs) { err := fs.Rmdir(remote) require.NoError(t, err) }
// TestRmdir tests Rmdir works func TestRmdir(t *testing.T, remote fs.Fs) { err := fs.Rmdir(remote) if err != nil { t.Fatalf("Rmdir failed: %v", err) } }
err := fs.Mkdir(fdst) if err != nil { log.Fatalf("Failed to mkdir: %v", err) } }, MinArgs: 1, MaxArgs: 1, }, { Name: "rmdir", ArgsHelp: "remote:path", Help: ` Remove the path. Note that you can't remove a path with objects in it, use purge for that.`, Run: func(fdst, fsrc fs.Fs) { err := fs.Rmdir(fdst) if err != nil { log.Fatalf("Failed to rmdir: %v", err) } }, MinArgs: 1, MaxArgs: 1, }, { Name: "purge", ArgsHelp: "remote:path", Help: ` Remove the path and all of its contents.`, Run: func(fdst, fsrc fs.Fs) { err := fs.Purge(fdst) if err != nil {
package rmdir import ( "github.com/ncw/rclone/cmd" "github.com/ncw/rclone/fs" "github.com/spf13/cobra" ) func init() { cmd.Root.AddCommand(commandDefintion) } var commandDefintion = &cobra.Command{ Use: "rmdir remote:path", Short: `Remove the path if empty.`, Long: ` Remove the path. Note that you can't remove a path with objects in it, use purge for that.`, Run: func(command *cobra.Command, args []string) { cmd.CheckArgs(1, 1, command, args) fdst := cmd.NewFsDst(args) cmd.Run(true, false, command, func() error { return fs.Rmdir(fdst, "") }) }, }