assertCorrectNumberOfArgs( args, 2, 2 );
assertConfigurationInitialized( );
CloudPath currentDir = CliSession.getSession( ).getCurrentDirectory( );
CloudStoreObject fromObj = null;
CloudStoreObject toObj = null;
for (String arg : args.getArguments())
{
CloudPath path = new CloudPath( arg , currentDir, CliSession.getSession( ).getCloudloop( ) );
if (fromObj == null)
{
boolean preferDirectory = false;
fromObj = CliUtil.extractObject( path, preferDirectory );
} else
{
boolean preferDirectory = ( fromObj.getStoreObjectType( ) == CloudStoreObjectType.DIRECTORY );
toObj = CliUtil.extractObject( path, preferDirectory );
}
}
// print copy progress if we're copying across stores
ProgressPrinter progressPrinter = null;
assert fromObj != null;
assert toObj != null;
if (!fromObj.getParentStore( ).equals( toObj.getParentStore( ) ))
{
fromObj.refreshMetadata( );
progressPrinter = new ProgressPrinter( out );
}
if (fromObj.getStoreObjectType( ) == CloudStoreObjectType.DIRECTORY)
{
if (toObj.getStoreObjectType( ) != CloudStoreObjectType.DIRECTORY)
{
err.println( "Cannot move directory '"
+ fromObj.getPath( ).getAbsolutePath( ) + "' to file '"
+ toObj.getPath( ).getAbsolutePath( ) + "'." );
return 1;
}
( (CloudStoreDirectory) fromObj ).copyTo(
(CloudStoreDirectory) toObj, progressPrinter );
} else
{
if (toObj.getStoreObjectType( ) == CloudStoreObjectType.DIRECTORY)
{
( (CloudStoreFile) fromObj ).copyTo(
(CloudStoreDirectory) toObj, progressPrinter );
} else
{