Exemple #1
0
void removeSequence( const sp::Sequence& s )
{
	std::ssize_t first;
	std::ssize_t last;
	if( selectRange )
	{
		first = std::max( s.getFirstTime(), firstImage );
		last  = std::min( s.getLastTime(), lastImage );
	}
	else
	{
		first = s.getFirstTime();
		last  = s.getLastTime();
	}
//	TUTTLE_TCOUT( "remove sequence." );
//	TUTTLE_TCOUT("remove from " << first << " to " << last);

	for( sp::Time t = first; t <= last; t += s.getStep() )
	{
		bfs::path sFile = s.getAbsoluteFilenameAt(t);
		if( !bfs::exists( sFile ) )
		{
			TUTTLE_CERR("Could not remove (file not exist): " << _color._red << sFile.string() << _color._std );
		}
		else
		{
			if(verbose)
			{
				TUTTLE_COUT("remove: " << _color._folder << sFile.string() << _color._std );
			}
			try
			{
				bfs::remove( sFile );
			}
			catch(const boost::filesystem::filesystem_error& e)
			{
//			   if( e.code() == boost::system::errc::permission_denied )
//				   "permission denied"
				TUTTLE_CERR( "sam-rm: Error:\t\n" << e.what() );
				/// @todo cin
//				TUTTLE_COUT( "sam-rm: Continue ? (Yes/No/Yes for All/No for All)" );
				
			}
		}
	}
}
Exemple #2
0
void copy_sequence( const sp::Sequence& s, const sp::Time firstImage, const sp::Time lastImage, const sp::Sequence& d, int offset = 0 )
{
	sp::Time begin;
	sp::Time end;
	sp::Time step;
	if (offset > 0) {
		begin = lastImage;
		end = firstImage;
		step = -s.getStep();
	} else {
		begin = firstImage;
		end = lastImage;
		step = s.getStep();
	}
	
	for( sp::Time t = begin;
		 (offset > 0) ? (t >= end) :
		 (t <= end); t += step )
	{
		bfs::path sFile = s.getAbsoluteFilenameAt(t);
		//TUTTLE_TLOG_VAR( TUTTLE_TRACE, sFile );
		if( bfs::exists( sFile) )
		{
			bfs::path dFile = d.getAbsoluteFilenameAt(t + offset);
			//TUTTLE_TLOG( TUTTLE_TRACE, "do " << sFile << " -> " << dFile );
#ifndef SAM_MOVEFILES // copy file(s)
			if( bfs::exists(dFile) )
			{
				TUTTLE_LOG_ERROR( "Could not copy: " << dFile.string( ) );
			}
			else
			{
				try
				{
					//TUTTLE_LOG_TRACE( "copy " << sFile << " -> " << dFile );
					bfs::copy_file(sFile, dFile);
				}
				catch (const bpo::error& e)
				{
					TUTTLE_LOG_ERROR( "error : " << e.what() );
				}
				catch (...)
				{
					TUTTLE_LOG_ERROR( boost::current_exception_diagnostic_information( ) );
				}
			}
#else // move file(s)
			if( bfs::exists( dFile ) )
			{
				TUTTLE_LOG_ERROR( "Could not move: " << dFile.string( ) );
			}
			else
			{
				try
				{
					//TUTTLE_LOG_TRACE( "move " << sFile << " -> " << dFile );
					bfs::rename( sFile, dFile );
				}
				catch( const bpo::error& e )
				{
					TUTTLE_LOG_ERROR( "error : " << e.what() );
				}
				catch( ... )
				{
					TUTTLE_LOG_ERROR( boost::current_exception_diagnostic_information( ) );
				}
			}
#endif
		}
	}
}