void Texture::CreateTextureFromFile(ID3D12GraphicsCommandList* gfx_command_list, const char* file)
{
	std::streampos size;
	uint8* tex_data;

	shared_context.log->LogText(LogLevel::DEBUG_PRINT, "Loading texture: %s", file);

	std::ifstream file_stream(file, std::ios::in | std::ios::binary | std::ios::ate);
	if (file_stream.is_open())
	{
		size = file_stream.tellg();
		tex_data = new uint8[size];
		file_stream.seekg(0, std::ios::beg);
		file_stream.read((char*)tex_data, size);
		file_stream.close();

		CreateDDSTextureFromMemory(gfx_command_list, tex_data, (uint32)size, &m_texture, &m_uploadTexture);

		if(m_texture != nullptr && m_uploadTexture != nullptr)
		{
			m_GPUhandle = shared_context.gfx_device->GetDescHeapCBV_SRV()->GetGPUHandleAtHead();
			shared_context.log->LogText(LogLevel::SUCCESS, "Texture loaded: %s", file);
		}
		delete[] tex_data;
	}
	else 
	{
		shared_context.log->LogText(LogLevel::FATAL_ERROR, "Texture load failed: %s", file);
	}
}
示例#2
0
int DilemmaModel::SetMatrixFromFile(const std::string & file)
{
    std::vector <std::vector <int> > temp_matrix;
    
    temp_matrix.resize(DilemmaModel::_MATRIX_SIZE_Y);
    for(std::vector<std::vector <int> >::iterator i = temp_matrix.begin(); i != temp_matrix.end(); i++)
    {
        (*i).resize(DilemmaModel::_MATRIX_SIZE_X, 0);
    }
    
    std::ifstream file_stream(file.c_str());
    
    for(int i = 0; i < DilemmaModel::_MATRIX_SIZE_Y; i++)
    {
        for(int j = 0; j < DilemmaModel::_MATRIX_SIZE_X; j++)
        {
            if(!(file_stream >> temp_matrix[i][j]))
            {
                return -1;
            }
        }
    }
    
    _matrix = temp_matrix;
    
    return 0;
}
示例#3
0
std::vector<std::vector<double> > * read_sample(const char * const path_file) {
	std::string filename(path_file);

	std::ifstream file_stream(filename.c_str(), std::fstream::in);
	if (!file_stream.is_open()) {
		return NULL;
	}

	std::string line;

	std::vector<std::vector<double> > * dataset = new std::vector<std::vector<double> >();

	while(std::getline(file_stream, line)) {
		std::istringstream parser(line);
		std::vector<double> point;

		double coordinate = 0.0;
		while(parser >> coordinate) {
			point.push_back(coordinate);
		}

		dataset->push_back(point);
	}

	file_stream.close();

	return dataset;
}
void J2716AnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
	std::ofstream file_stream( file, std::ios::out );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	file_stream << "Time [s],Value" << std::endl;

	U64 num_frames = GetNumFrames();
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
		
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char number_str[128];
		AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );

		file_stream << time_str << "," << number_str << std::endl;

		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			file_stream.close();
			return;
		}
	}

	file_stream.close();
}
示例#5
0
bool World_wrapper::save_transform(const std::string& folder_name){

    std::string folder_save = path_to_save + "/" + folder_name;
    if( !(boost::filesystem::exists(folder_save) && boost::filesystem::is_directory(folder_save) )){
        if (boost::filesystem::create_directory(folder_save)){
            std::cout << "new folder " + folder_name + " created" << "\n";
        }else{
            std::cerr << "FAILED to create new folder " + folder_name << "\n";
            return false;
        }
    }

    // save all the urdf transformation
    for(auto it = positions.begin(); it != positions.end(); it++){
        std::string file_name = folder_save + "/" + it->first + ".csv";
        std::ofstream file_stream(file_name);
        if(file_stream.is_open()){
            std::array<float,6>& p = it->second;
            file_stream << p[0] << "," << p[1] << "," << p[2] << "," << p[3] << ","
                        << p[4] << "," << p[5] << std::endl;
            file_stream.close();
        }else{
            std::cerr << " FAILED to open: " + file_name << std::endl;
            return false;
        }
    }


    return true;
}
PlotRet plot_graph(GraphDataType const & graph, const char file_name[], const string name_graph, vector<string> & name_vtxes) {
    std::ofstream file_stream(file_name);
    if(false == file_stream.is_open()) {
        return PlotRet::fail_to_open_file;
    }
    file_stream << "digraph " << name_graph << "{\n";
    int count = graph.size();
    int r=0;
    int c=0;
    //cout << count<< endl;
    for(r=0;r<count; ++ r) {
        //cout <<graph[r].size() << endl;
        for(c=0;c<count;++c) {
            
            if(graph[r][c] > 0){
                file_stream << name_vtxes[r] << "->" << name_vtxes[c]<< "\n";
            }
        }
    }
    file_stream << "}" << endl;
    string cmd{"dot -Tpng "};
    cmd += file_name;
    cmd += (" -o ./"+ name_graph + ".png");
    std::cout << cmd << endl;
    system(cmd.c_str());
    return PlotRet::success;
}
PlotRet plot_graph_flow(GraphDataType const & graph, const string name_graph, vector<string> & name_vtxes) {
    string file_name =name_graph + ".dot";
    std::ofstream file_stream(file_name);
    if(false == file_stream.is_open()) {
        return PlotRet::fail_to_open_file;
    }
    file_stream << "digraph " << name_graph << "{\n";
    int count = graph.size();
    int r= 0;
    int c= 0;
    ////-- #1 plot vertex label.
    //for(r = 0; r< count ; ++r ) {
       //cout << r << "[label=jj" 

    //}
    //-- #2 plot line label.
    for(r=0; r<count ;++r) {
        for(c=0; c<count; ++c) {
            if(graph[r][c] > 0) {
                file_stream << name_vtxes[r] << "->" << name_vtxes[c] << " [label=\""<<graph[r][c] << "\", fontcolor=darkgreen]\n";
            }
        }
    }
    file_stream << "}" << endl;
    string cmd{"dot -Tpng "};
    cmd += file_name;
    cmd += (" -o ./"+name_graph+".png");
    std::cout <<cmd << endl;
    system(cmd.c_str());
    return PlotRet::success;
}
示例#8
0
	bool
	ClientImpl::sync_download(
		std::string remote_file, 
		std::string local_file, 
		callback_t callback, 
		progress_t progress
	) noexcept
	{
		bool is_existed = this->check(remote_file);
		if (!is_existed) return false;

		auto root_urn = Urn(this->webdav_root, true);
		auto file_urn = root_urn + remote_file;

		std::ofstream file_stream(local_file, std::ios::binary);

		Request request(this->options());

		auto url = this->webdav_hostname + file_urn.quote(request.handle);

		request.set(CURLOPT_CUSTOMREQUEST, "GET");
		request.set(CURLOPT_URL, url.c_str());
		request.set(CURLOPT_HEADER, 0L);
		request.set(CURLOPT_WRITEDATA, (size_t)&file_stream);
		request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Write::stream);
		if (progress != nullptr) {
			request.set(CURLOPT_XFERINFOFUNCTION, (size_t)progress.target<progress_funptr>());
			request.set(CURLOPT_NOPROGRESS, 0L);
		}

		bool is_performed = request.perform();

		if (callback != nullptr) callback(is_performed);
		return is_performed;
	}
示例#9
0
void DistributedObject::commit(const DistributedWriteLock& dist_lock, const ReadableLock& lock) const
{
	lock.check_read(get_local_mutex());

	if (!persistence_enabled_)
	{
		const_cast<DistributedObject*>(this)->timestamp_ = time(NULL);
		return;
	}

	if (&dist_lock.get_object() != this)
		throw std::runtime_error("Distributed lock has incorrect object");
	if (file_.string().empty())
		throw std::runtime_error("Distributed object has no associated file");

	try
	{
		std::ofstream file_stream(get_file().string().c_str());
		if (!file_stream)
			throw bfs::filesystem_error("open failed", get_file(), bs::error_code(errno, boost::system::posix_category));

		OutputArchive file_arch(file_stream);
		do_save(file_arch, lock);
		file_stream.flush();
		const_cast<DistributedObject*>(this)->timestamp_ = bfs::last_write_time(file_);
	}
	catch (bfs::filesystem_error& e)
	{
		throw distributed_object_error("file error: " + std::string(e.what()));
	}
	catch (boost::archive::archive_exception& e)
	{
		throw distributed_object_error("serialization error: " + std::string(e.what()));
	}
}
示例#10
0
bool DistributedObject::update(const DistributedLock& dist_lock, UpgradableReadLock& lock)
{
	lock.check_read(get_local_mutex());

	if (!persistence_enabled_)
		return false;

	throw std::runtime_error("Persistence currently not implemented");
#if 0
	if (&dist_lock.get_object() != this)
		throw std::runtime_error("Distributed lock has incorrect object");
	if (file_.string().empty())
		throw std::runtime_error("Distributed object has no associated file");

	try
	{
		{
			flush_cache();

			/* load from the file */
			std::ifstream file_stream(get_file().string().c_str());
			if (!file_stream)
				throw bfs::filesystem_error("open failed", get_file(), bs::error_code(errno, boost::system::posix_category));

			/* see if the file has changed, do nothing if it hasn't */
			time_t write_time = bfs::last_write_time(file_);
			if (write_time == timestamp_)
				return false;

			/* create a temporary instance to which the file will be loaded */
			DistributedObjectPtr temp_obj = boost::dynamic_pointer_cast<DistributedObject>(create_empty_instance());
			if (!temp_obj)
				throw std::runtime_error("Distributed object failed to create temporary instance");

			/* need an exclusive lock on the temporary object */
			BlockWriteLock temp_obj_lock(*temp_obj);

			InputArchive file_arch(file_stream);
			temp_obj->do_load(file_arch, temp_obj_lock);

			/* temporarily upgrade to a write lock for our local object and then apply the updates */
			BlockWriteLock write_lock(lock);
			copy_from(temp_obj, temp_obj_lock, write_lock);
		}

		/* update the timestamp */
		timestamp_ = bfs::last_write_time(file_);
	}
	catch (bfs::filesystem_error& e)
	{
		throw distributed_object_error("file error: " + std::string(e.what()));
	}
	catch (boost::archive::archive_exception& e)
	{
		throw distributed_object_error("deserialization error: " + std::string(e.what()));
	}
#endif
	return true;
}
示例#11
0
  void load(const std::string &filename, vector<unique_ptr<Trellis>> &trellis_buffer) {
    ifstream file_stream(filename);
    IStreamWrapper stream_wrapper(file_stream);
    Document document;
    document.ParseStream(stream_wrapper);

    load_trellises(document["trellises"], trellis_buffer);
  }
示例#12
0
void FileReader::loadFile(std::string file_path, size_t i){//, Page::PagePtr page) { 
  std::ifstream file_stream(file_path);
  file_stream.seekg(0, std::ios::end);
  size_t size = file_stream.tellg();
  std::string buffer(size, ' ');
  file_stream.seekg(0);
  file_stream.read(&buffer[0], size); 
  file_stream.close();
  Page::PagePtr p = getPages()[i];
  p->retrieveWords(buffer);
}
示例#13
0
bool LayeredMeshGenerator::allRastersExist(std::vector<std::string> const& raster_paths) const
{
    for (auto raster = raster_paths.begin(); raster != raster_paths.end(); ++raster)
    {
        std::ifstream file_stream (*raster, std::ifstream::in);
        if (!file_stream.good())
            return false;
        file_stream.close();
    }
    return true;
}
示例#14
0
文件: sexpr.C 项目: bougyman/sfs
int
main (int argc, char **argv)
{
  stream *s = (argc > 1) ? New buf_stream (argv[1], strlen (argv[1]))
                         : New file_stream (stdin);
  gob *g = g_read (s);
  if (g)
    g->fwrite (stderr);
  else
    fprintf (stderr, "-- Error reading input");
  fprintf (stderr, "\n");
}
示例#15
0
bash_ast::bash_ast(const std::string& script_path,
                   std::function<pANTLR3_BASE_TREE(plibbashParser)> p,
                   bool trim): parse(p)
{
  std::stringstream stream;
  std::ifstream file_stream(script_path);
  if(!file_stream)
    throw libbash::parse_exception(script_path + " can't be read");

  read_script(file_stream, trim);
  init_parser(script_path);
}
示例#16
0
std::string Task::GetCpuSetPath() const {
  if (auto file = OpenTaskFilePointer("cpuset")) {
    stdio_filebuf<char> filebuf(file.get());
    std::istream file_stream(&filebuf);

    std::string line = "";
    std::getline(file_stream, line);

    return Trim(line);
  } else {
    return "";
  }
}
void SDIOAnalyzerResults::GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id )
{
	std::ofstream file_stream( file, std::ios::out );

	U64 trigger_sample = mAnalyzer->GetTriggerSample();
	U32 sample_rate = mAnalyzer->GetSampleRate();

	file_stream << "Time [s],Value" << std::endl;

	U64 num_frames = GetNumFrames();
	for( U32 i=0; i < num_frames; i++ )
	{
		Frame frame = GetFrame( i );
		
		char time_str[128];
		AnalyzerHelpers::GetTimeString( frame.mStartingSampleInclusive, trigger_sample, sample_rate, time_str, 128 );

		char number_str[128];
		AnalyzerHelpers::GetNumberString( frame.mData1, display_base, 8, number_str, 128 );

		file_stream << time_str << ",";
		
		if (frame.mType == SDIOAnalyzer::FRAME_DIR){
			file_stream << "DIR:";
			if (frame.mData1){
				file_stream << "from Host";
			}else{
				file_stream << "from Slave";
			}
		}else if (frame.mType == SDIOAnalyzer::FRAME_CMD){
			file_stream << "CMD:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_ARG){
			file_stream << "ARG:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_LONG_ARG){
			file_stream << "LONG_ARG:" << number_str;
		}else if (frame.mType == SDIOAnalyzer::FRAME_CRC){
			file_stream << "CRC:" << number_str;
		}
		
		file_stream << std::endl;

		if( UpdateExportProgressAndCheckForCancel( i, num_frames ) == true )
		{
			file_stream.close();
			return;
		}
	}

	file_stream.close();
}
示例#18
0
void DigestFilePair::calculate( const fs::path file ) {
	fs::ifstream file_stream( file );
	CryptoPP::FileSource fsource( file_stream, true );
	CryptoPP::SHA512 sha;
	byte digest[sha.DigestSize()];
	byte *data = new byte[ fsource.MaxRetrievable() ];
	size_t size = fsource.Get( data, fsource.MaxRetrievable() );
	sha.CalculateDigest( digest, data, size );
	std::stringstream ss;
	for(int i = 0; i < sha.DigestSize(); i++)
		ss << std::hex << std::setw(2) << std::setfill('0') << (int) digest[i];
	delete[] data;
	_digest = ss.str();
	_file = file;
}
示例#19
0
intrusive_ptr<IDocument>
JAG_CALLSPEC create_file(Char const* file_path, intrusive_ptr<IProfile> config)
{
    // create a file stream
    shared_ptr<ISeqStreamOutputControl> file_stream (
        new jstd::MMapFileStreamOutput(file_path)
   );

    // prepare a config object
    intrusive_ptr<IProfileInternal> cfg_internal = config
        ? checked_static_pointer_cast<IProfileInternal>(config)
        : intrusive_ptr<IProfileInternal>(new RefCountImpl<jstd::ConfigImpl,RefCountMT>(pdf::s_config_symbols));

    return new RefCountImpl<pdf::DocWriterImpl>(file_stream, cfg_internal);
}
示例#20
0
std::string MusicDay::read_file_into_string(std::string filename) {
    std::string line;
    std::ifstream file_stream("music_day_files/" + filename);
    std::string string_of_file;
    if (file_stream.is_open()) {
        while (std::getline (file_stream, line)) {
            string_of_file += line + "\n";
        }
        file_stream.close();
    }
    else {
        std::cout << "Unable to open file";
    }
    file_stream.close();
    return string_of_file;
}
示例#21
0
void MainWindow::on_actionSave_Ctrl_s_triggered()
{
    if(path1.isEmpty()){
        path1 = QFileDialog::getSaveFileName(this,"Save...",".",tr("Bat Files(*.bat);;TextFiles(*.txt);;All Files(*.*)"));
        if(path1.isEmpty()) return;
    }
    QFile file_path(path1);
    if(!file_path.open(QIODevice::WriteOnly|QIODevice::Text)){
            QMessageBox::warning(this,tr("ReadFile"),tr("The Path is not valid"));
            return;
    }

    QTextStream file_stream(&file_path);
    file_stream << ui ->codeeditor-> toPlainText();
    file_path.close();
}
示例#22
0
文件: qImage.hpp 项目: qiangd6/QTK
			///
			/// LDR I/O, only available to LDR images
			void LoadBmp(const std::string& file_name)
			{
				BOOST_STATIC_ASSERT( (boost::is_same<T, UCHAR>::value) );
				BOOST_STATIC_ASSERT( channel == 3 );

				size_t pos = file_name.find_last_of(".");
				std::string file_type = file_name.substr(++pos, std::string::npos);
				boost::to_lower(file_type);
				assert(file_type == "bmp");
				
				BITMAPFILEHEADER bitmap_file_header;
				BITMAPINFOHEADER bitmap_info_header;

				//open filename in read binary mode
				std::fstream file_stream(file_name.c_str(), std::ios::in | std::ios::binary);
				if(!file_stream) 
				{
					assert(0);
					return;
				}

				//file header
				file_stream.read((char*)&bitmap_file_header, sizeof(BITMAPFILEHEADER));
				if (bitmap_file_header.bfType != 0x4D42)
				{
					file_stream.close();
					assert(0);
					return;
				}

				//info header
				file_stream.read((char*)&bitmap_info_header, sizeof(BITMAPINFOHEADER));
				file_stream.seekg(bitmap_file_header.bfOffBits, std::ios_base::beg);

				SetSize(bitmap_info_header.biWidth, bitmap_info_header.biHeight);

				//actual data
				file_stream.read((char*)GetData(), sizeof(char) * bitmap_info_header.biWidth * bitmap_info_header.biHeight * GetChannel());
				file_stream.close();

				//convert bgr to rgb
				for (UINT i = 0; i < bitmap_info_header.biWidth * bitmap_info_header.biHeight * GetChannel(); i += GetChannel())
					std::swap(GetData()[i], GetData()[i + 2]);

			}
示例#23
0
std::string load_ssl_certificate(const std::string filename) {
  // Open the file
  std::ifstream file_stream(filename.c_str(), std::ios::in | std::ios::binary | std::ios::ate);

  BOOST_REQUIRE_MESSAGE(file_stream.is_open(), "Unable to load certificate file: " << filename);

  // Get the length of the file
  std::ifstream::pos_type file_size = file_stream.tellg();
  file_stream.seekg(0, std::ios::beg);

  BOOST_REQUIRE_MESSAGE(file_size > 0, "No data in certificate file: " << filename);

  // Read the file into memory
  std::vector<char> bytes(file_size);
  file_stream.read(&bytes[0], file_size);

  std::string certificate(&bytes[0], file_size);
  return certificate;
}
示例#24
0
void MainWindow::on_actionSave_As_triggered()
{
    QString temp_path = path1;
    path1 = QFileDialog::getSaveFileName(this,"Save As...",".",tr("Bat Files(*.bat);;TextFiles(*.txt);;All Files(*.*)"));
    if(!path1.isEmpty()){
       QFile file_path(path1);
       if(!file_path.open(QIODevice::WriteOnly|QIODevice::Text)){
               return;
       }
       QTextStream file_stream(&file_path);
       file_stream << ui ->codeeditor-> toPlainText();
       file_path.close();

   }else{
         //QMessageBox::warning(this,tr("ReadFile"),tr("The Path haven't been selected."));
   }
   if(if_opened) {
       path1 = temp_path;
   }
}
示例#25
0
	std::string ShaderProgram::file_contents_to_string(const char* file_path){
		std::string content;
		std::ifstream file_stream(file_path, std::ios::in);

		if (!file_stream.is_open()) {
			std::cerr << "Could not read file " << file_path << ". File does not exist." << std::endl;
			return "";
		}

		std::string line = "";
		while (!file_stream.eof()) {
			std::getline(file_stream, line);
			content.append(line + "\n");
		}

		file_stream.close();


		return content;
	}
示例#26
0
StatusLine		FileReader::get_from_file(const std::string& full_path,Entity& saver )
{

    std::ifstream file_stream(full_path.c_str(),std::ios::in | std::ios::binary);
    if (! file_stream.is_open()) {
		return  StatusLine(http_500,"fail to open file");
    }
    while (!file_stream.eof() ) {
		saver.data().ensure_write_space(m_read_block_size);
        file_stream.read(saver.data().wt_ptr(),m_read_block_size) ; 
		saver.data().has_written(file_stream.gcount());
	}
	saver.head().get_container()[HeadFields::EntityFields::ent_content_length]=
		StringHelper::integer_to_string<size_t>((size_t)saver.data().readable_bytes());

	save_to_cache(full_path,saver);
	return StatusLine(http_200,"");
	

}
示例#27
0
    /// <summary>
    /// Read file as an XLSX-formatted ZIP file in the filesystem to a workbook,
    /// write the workbook back to memory, then ensure that the contents of the two files are equivalent.
    /// </summary>
	bool round_trip_matches_rw(const xlnt::path &original)
	{
        std::ifstream file_stream(original.string(), std::ios::binary);
        std::vector<std::uint8_t> original_data;

        {
            xlnt::detail::vector_ostreambuf file_data_buffer(original_data);
            std::ostream file_data_stream(&file_data_buffer);
            file_data_stream << file_stream.rdbuf();
        }

		xlnt::workbook original_workbook;
		original_workbook.load(original);
        
        std::vector<std::uint8_t> buffer;
        original_workbook.save(buffer);
        original_workbook.save("round_trip_out.xlsx");

		return xml_helper::xlsx_archives_match(original_data, buffer);
	}
示例#28
0
void MainWindow::on_actionOpen_File_Ctrl_O_triggered()
{
    if_opened = true;
    path1 = QFileDialog::getOpenFileName(this,"Open...",".",tr("Bat Files(*.bat);;TextFiles(*.txt);;All Files(*.*)"));
    if(!path1.isEmpty()){
        QFile file_path(path1);
        if(!file_path.open(QIODevice::ReadOnly))
        {
                QMessageBox::warning(this,tr("ReadFile"),tr("Connot open:\n %1").arg(path1));
                return;

        }
        QTextStream file_stream(&file_path);
        ui ->codeeditor -> setPlainText(file_stream.readAll());
        file_path.close();

    }else{
          //QMessageBox::warning(this,tr("ReadFile"),tr("The Path haven't been selected."));
    }
}
示例#29
0
	bool
	ClientImpl::sync_upload(
		std::string remote_file, 
		std::string local_file, 
		callback_t callback, 
		progress_t progress
	) noexcept
	{
		bool is_existed = FileInfo::exists(local_file);
		if (!is_existed) return false;

		auto root_urn = Urn(this->webdav_root, true);
		auto file_urn = root_urn + remote_file;

		std::ifstream file_stream(local_file, std::ios::binary);
		auto size = FileInfo::size(local_file);

		Request request(this->options());

		auto url = this->webdav_hostname + file_urn.quote(request.handle);

		Data response = { 0, 0, 0 };

		request.set(CURLOPT_UPLOAD, 1L);
		request.set(CURLOPT_URL, url.c_str());
		request.set(CURLOPT_READDATA, (size_t)&file_stream);
		request.set(CURLOPT_READFUNCTION, (size_t)Callback::Read::stream);
		request.set(CURLOPT_INFILESIZE_LARGE, (curl_off_t)size);
		request.set(CURLOPT_BUFFERSIZE, (long)Client::buffer_size);
		request.set(CURLOPT_WRITEDATA, (size_t)&response);
		request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Append::buffer);
		if (progress != nullptr) {
			request.set(CURLOPT_XFERINFOFUNCTION, (size_t)progress.target<progress_funptr>());
			request.set(CURLOPT_NOPROGRESS, 0L);
		}

		bool is_performed = request.perform();

		if (callback != nullptr) callback(is_performed);
		return is_performed;
	}
示例#30
0
void
flake::planar::conversion::object::scalar_to_matlab_file(
	flakelib::planar::float_view const &_view,
	boost::filesystem::path const &_file)
{
	boost::filesystem::ofstream file_stream(
		_file);

	if(!file_stream.is_open())
		throw
			flake::exception(
				FCPPT_TEXT("Couldn't open file \"")+
				fcppt::filesystem::path_to_string(
					_file)+
				FCPPT_TEXT("\""));

	sge::opencl::command_queue::scoped_buffer_mapping buffer_mapping(
		command_queue_,
		_view.buffer(),
		sge::opencl::command_queue::map_flags::read,
		sge::opencl::memory_object::byte_offset(
			0u),
		_view.buffer().byte_size(),
		sge::opencl::event::sequence());

	cl_float const *p =
		static_cast<cl_float const *>(
			buffer_mapping.ptr());

	for(sge::opencl::size_type y = 0; y < _view.size().h(); ++y)
	{
		for(sge::opencl::size_type x = 0; x < _view.size().w(); ++x)
		{
			file_stream << (*p++);
			if(x < (_view.size().w()-1u))
				file_stream << ",";
		}
		if(y < (_view.size().h()-1u))
			file_stream << "\n";
	}
}