void dir_cpi_impl::sync_remove (saga::impl::void_t & ret, saga::url url, int flags)
{
    adaptor_data_t AdaptorData(this);
    directory_instance_data_t InstanceData(this);
    
    this->throw_if_local(InstanceData->location_);
    this->check_if_open ("dir_cpi_impl::sync_remove", InstanceData->location_);
    
    saga::url u = merge_urls(InstanceData->location_.get_url(), url);
    
    GridFTPConnection * ConnectionHandle = 
    AdaptorData->getConnectionHandleForURL(u, write_log_, logfile_loc_);
    
    try 
    {
        if( ConnectionHandle->is_dir( u.get_url() ) )
        {
            if(flags & saga::filesystem::Recursive)
            {
                saga::filesystem::directory basedir(u);
                std::vector<saga::url> entries = basedir.list();
                for(unsigned int i = 0; i < entries.size(); ++i)
                {
                    if(basedir.is_dir(entries[i]))
                    {
                        basedir.remove(entries[i], saga::filesystem::Recursive);
                    }
                    else
                    {
                        basedir.remove(entries[i], saga::filesystem::None);
                    }
                }
                ConnectionHandle->remove_directory( u.get_url() );
            }
        }
        else
        {
            ConnectionHandle->remove_file( u.get_url() );
        }
    }
    catch( globus_gridftp_file_adaptor::exception const & e )
    {
        error_package ep = globus_gridftp_file_adaptor
        ::error_default_redirect(e, u.get_url());
        
        SAGA_OSSTREAM strm;
        strm << "Could not remove [" << u << "]. " << ep.error_text;        
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), ep.saga_error);
	}
}
Пример #2
0
void file_cpi_impl::sync_remove (saga::impl::void_t & ret,
                                 int flags)
{
    adaptor_data_t AdaptorData(this);
    file_instance_data_t InstanceData (this);
        
	try {
		GridFTPConnection * ConnectionHandle = 
			AdaptorData->getConnectionHandleForURL(InstanceData->location_);  
    
		ConnectionHandle->remove_file( InstanceData->location_.get_url() );
    }
    catch( curl_file_adaptor::exception const & e )
    {
        error_package ep = curl_file_adaptor
        ::error_default_redirect(e, InstanceData->location_.get_url());
        SAGA_OSSTREAM strm;
        strm << "Could not remove [" << InstanceData->location_ << "]. " << ep.error_text;        
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), ep.saga_error);
    }
}