当前位置: 首页>>代码示例>>C++>>正文


C++ saga::url类代码示例

本文整理汇总了C++中saga::url的典型用法代码示例。如果您正苦于以下问题:C++ url类的具体用法?C++ url怎么用?C++ url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了url类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: removeConnectionHandle

//// connection pool handling - remove a handle //////////////////////////////
//
void adaptor::removeConnectionHandle (const saga::url url)
{
    // extract protocol, server & port from given url
    std::string location("");
    location.append(url.get_scheme());
    location.append("://");
    location.append(url.get_host());
    
    if( RLSConnectionPool_ == NULL )
    {
        return;
    }
    else
    {
        RLSConnectionPool_->erase(location);
    }
}
开发者ID:saga-project,项目名称:saga-cpp-adaptor-globus,代码行数:19,代码来源:globus_rls_replica_adaptor.cpp

示例2: adaptorData

    void logical_file_cpi_impl::sync_update_location(saga::impl::void_t& ret, 
                                                     saga::url oldlocation, saga::url newlocation)
    {
        adaptor_data_t  adaptorData(this);
        instance_data   instanceData (this);
        saga::url lfn_url(instanceData->location_);
        
        this->check_if_open ("logical_file_cpi_impl::sync_update_location", instanceData->location_);
        
        check_permissions(saga::replica::Write, "update_location", lfn_url.get_url());
        
        bool oldExists = false; // worst case - update will fail
        bool newExists = true;  //
        
        SAGA_OSSTREAM strm;
        strm << "Could not update location for logical file ["
        << instanceData->location_ << "]. ";
        
        try {
            RLSConnection * RLSHandle = 
			adaptorData->getConnectionHandle(instanceData->location_);
            oldExists = RLSHandle->LFNtoPFNMappingExists(lfn_url.get_path(), 
                                                         oldlocation.get_url());
            newExists = RLSHandle->LFNtoPFNMappingExists(lfn_url.get_path(), 
                                                         newlocation.get_url());
        }
        catch(globus_rls_replica_adaptor::exception const & e)
        {
            strm << e.RLSErrorText();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), e.SAGAError()); 
        }
        
        if(!oldExists) {
            strm << "PFN: [" << oldlocation << "] doesn't exist!";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::DoesNotExist);
        }
        
        if(newExists) {
            strm << "PFN: [" << newlocation << "] already exist!";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::AlreadyExists);
        }
        
        // everyting seems to be ok. let's update the LFN
        sync_add_location(ret, newlocation);
        sync_remove_location(ret, oldlocation);
    }
开发者ID:saga-project,项目名称:saga-cpp-adaptor-globus,代码行数:46,代码来源:globus_rls_replica_adaptor_logicalfile_impl.cpp

示例3: mount_sshfs

  TR1::shared_ptr <sshfs> filesystem_adaptor::get_sshfs (const saga::session & s, 
                                                         const saga::url     & u)
  {
    // only mount anything if the URL is ssh (or any) based
    if ( u.get_scheme () != "ssh" &&
         u.get_scheme () != "any" )
    {
      SAGA_ADAPTOR_THROW_NO_CONTEXT ("Cannot mount sshfs for non-ssh urls", 
                                     saga::BadParameter);
    }

    return mount_sshfs (s, u);
  }
开发者ID:carriercomm,项目名称:saga-cpp-adaptor-ssh,代码行数:13,代码来源:sshfs_file_adaptor.cpp

示例4: is_absolute

 bool filesystem_adaptor::is_absolute (const saga::url & u)
 {
   if ( u.get_scheme   ().empty ()  &&
        u.get_host     ().empty ()  &&
        u.get_username ().empty ()  &&
        u.get_password ().empty ()  &&
        u.get_port     ()    == -1  &&
        u.get_path     ()[0] != '/' )
   {
     return false;
   }
   
   return true;
 }
开发者ID:carriercomm,项目名称:saga-cpp-adaptor-ssh,代码行数:14,代码来源:sshfs_file_adaptor.cpp

示例5: remove_drive

 inline void remove_drive(saga::url& u)
 {
   std::string p(u.get_path());
   if (p.size() >= 2 && std::isalpha(p[0]) && p[1] == ':')
     u.set_path(p.substr(2));
 }
开发者ID:saga-project,项目名称:saga-cpp,代码行数:6,代码来源:test_api.hpp

示例6: compare

double compare(saga::url testUrl, saga::url baseUrl) {
   // Need to create tmp names, since I need ImageMagick to understand the names
   // therefore I need to copy the images to those files
   // If I can get imagemagick to read directly from the url, I woudn't waste
   // the time in copying files...  
   char tName[] = "/tmp/testImgXXXXXX";
   char bName[] = "/tmp/baseImgXXXXXX";
   std::cerr << "about to generate names!" << std::endl;
   int testFile = mkstemp(tName);
   std::cerr << "got one (" << tName << ")" << std::endl;
   if(testFile == -1) 
      perror(NULL);
   int baseFile = mkstemp(bName);
   std::cerr << "got two (" << bName << ")" << std::endl;
   if(baseFile == -1) 
      perror(NULL);

   std::cerr << "Before copying the files... " << std::endl; 
   
   saga::size_t const KB64 = 1024*64; //64KB
   saga::size_t bytesRead;
   std::cerr << "about to open files (" << testUrl.get_string() << ", " << baseUrl.get_string() << ")" << std::endl;
   saga::filesystem::file test(testUrl, saga::filesystem::Read);
   std::cerr << "1opened!" << std::endl;
   saga::filesystem::file base    (baseUrl    , saga::filesystem::Read);
   std::cerr << "2opened!" << std::endl;
   
   char data[KB64+1];
   std::cerr << "about to read" << std::endl;
   try {
      while((bytesRead = test.read(saga::buffer(data,KB64)))!=0) {
         std::cerr << "read from testFile" << std::endl;
         int retval = write(testFile, data, bytesRead);
         if(retval < 0)
            perror(NULL);
      }
   }
   catch(saga::exception const & e) {
      std::cerr << "Exception caught: " << e.what() << std::endl;
   }
   test.close();
   fsync(testFile);
   close(testFile);
   try {
      while((bytesRead = base.read(saga::buffer(data,KB64)))!=0) {
         std::cerr << "read from baseFile" << std::endl;
         std::cerr << "size = " << base.get_size() << std::endl;
         int retval = write(baseFile, data, bytesRead);
         if(retval < 0)
            perror(NULL);
      }
   }
   catch(saga::exception const & e) {
      std::cerr << "Exception caught: " << e.what() << std::endl;
   }
   base.close();
   fsync(baseFile);
   close(baseFile);
   
   std::cerr << "Just before Image magick" << std::endl;
   
   MagickWand *magick_wand_1;
   MagickWand *magick_wand_2;
   MagickWand *compare_wand;
   double difference;
   MagickBooleanType status_1, status_2;
   
   MagickWandGenesis();
   magick_wand_1=NewMagickWand();
   status_1=MagickReadImage(magick_wand_1,bName);
   if (status_1 == MagickFalse)
	   ThrowWandException(magick_wand_1);
   MagickWandGenesis();
   magick_wand_2=NewMagickWand();
   status_2=MagickReadImage(magick_wand_2,tName);
   if (status_2 == MagickFalse)
	   ThrowWandException(magick_wand_2);
   compare_wand = NewMagickWand();
   compare_wand=MagickCompareImages(magick_wand_1,magick_wand_2, AbsoluteErrorMetric, &difference);
   std::cerr << "Difference is: " << difference << std::endl;
   
   DestroyMagickWand(magick_wand_1);
   DestroyMagickWand(magick_wand_2);

   MagickWandTerminus();
   remove(bName);
   remove(tName);
   return difference;
}
开发者ID:saga-project,项目名称:saga-cpp-legacy-projects,代码行数:89,代码来源:compare.cpp

示例7: AdaptorData

void dir_cpi_impl::sync_copy (saga::impl::void_t & ret, saga::url src, 
                              saga::url dst, int flags)
{
    adaptor_data_t AdaptorData(this);
    directory_instance_data_t InstanceData (this);
    
    if(dst.get_scheme().empty() && dst.get_host().empty())
    {
        SAGA_OSSTREAM strm;
        strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
        << "]. Please specify scheme and/or hostname.";
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);                                     
    }
    
    if(dst.get_scheme() == "file")
    {
    	if(dst.get_host() != "localhost") {
            SAGA_OSSTREAM strm;
            strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
            << "]. If target URL scheme is 'file://', only 'localhost' is accepted as host.";
           SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);   
        }
        
        // avoid file:// -> file:// copy.
        if (InstanceData->location_.get_scheme() != "gridftp" 
	     && InstanceData->location_.get_scheme() != "gsiftp")
	    {
            SAGA_OSSTREAM strm;
            strm << "Cannot copy file [" << InstanceData->location_ << "]. " 
                 << "Supported source URL schemes are: gridftp:// and gsiftp://";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
	    }           

    }
    else
    {
        if(dst.get_scheme() != "gridftp" && dst.get_scheme() != "gsiftp" )
        {
            SAGA_OSSTREAM strm;
            strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
            << "]. Only gridftp:// and gsiftp:// and file:// schemes are supported for target urls.";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);         
        }
    }
        
    this->check_if_open ("dir_cpi_impl::sync_copy", InstanceData->location_);
    
    saga::url u_src = merge_urls(InstanceData->location_.get_url(), src);
    saga::url u_dst = merge_urls(InstanceData->location_.get_url(), dst);
    
    try {
        
        GridFTPConnection * ConnectionHandle = 
        AdaptorData->getConnectionHandleForURL(InstanceData->location_, write_log_, logfile_loc_);
        
        if(ConnectionHandle->exist(u_dst.get_url())) {
			if(ConnectionHandle->is_dir(u_dst.get_url())) {
				std::string url_path = u_dst.get_path();
				if(url_path.rfind("/") != url_path.length()-1) url_path.append("/");
				saga::url this_name; this->sync_get_name(this_name);
				url_path.append(this_name.get_path());
				u_dst.set_path(url_path);
            }
		}
        ConnectionHandle->copy_url(u_src.get_url(), u_dst.get_url());
    }
    catch( globus_gridftp_file_adaptor::exception const & e )
    {
        error_package ep = globus_gridftp_file_adaptor
        ::error_default_redirect(e, u_src.get_url());
        SAGA_OSSTREAM strm;
        strm << "Could not copy [" << u_src << " -> " << u_dst
        << "]. " << ep.error_text;
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), ep.saga_error);  
    }
    
}
开发者ID:saga-project,项目名称:saga-cpp-adaptor-globus,代码行数:77,代码来源:globus_gridftp_file_adaptor_dir_nsdir_impl.cpp


注:本文中的saga::url类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。