Example #1
0
bool Provider_System::itPrivateKey(Handle<std::string> uri, int *enc){
	LOGGER_FN();

	bool res = false;

	std::string symbol = "-";
	std::string privkeyHeader = "-----BEGIN PRIVATE KEY-----";
	std::string encPrivkeyHeader = "-----BEGIN ENCRYPTED PRIVATE KEY-----";
	std::string tempHeader = "-----";

	std::ifstream fileStream(uri->c_str(), std::ifstream::binary);
	fileStream.seekg(5);

	std::string line;
	std::getline(fileStream, line, symbol[0]);

	fileStream.close();

	tempHeader = tempHeader + line + "-----";

	if (strcmp(privkeyHeader.c_str(), tempHeader.c_str()) == 0){
		res = true;
		*enc = 0;
	}
	else if (strcmp(encPrivkeyHeader.c_str(), tempHeader.c_str()) == 0){
		res = true;
		*enc = 1;
	}

	return res;
}
Example #2
0
void ROICollection::load(const std::string& filename)
    throw (SerializationException)
{
    // open file for reading
    std::fstream fileStream(filename.c_str(), std::ios_base::in);
    if (fileStream.fail()) {
        throw SerializationException("Failed to open ROICollection file '" + tgt::FileSystem::absolutePath(filename) + "' for reading.");
    }

    // read data stream into deserializer
    XmlDeserializer d(FileSys.dirName(filename));
    d.setUseAttributes(true);
    try {
        d.read(fileStream);
    }
    catch (SerializationException& e) {
        throw SerializationException("Failed to read serialization data stream from ROICollection file '"
                                     + filename + "': " + e.what());
    }
    catch (...) {
        throw SerializationException("Failed to read serialization data stream from ROICollection file '"
                                     + filename + "' (unknown exception).");
    }

    // deserialize ROICollection from data stream
    try {
        d.deserialize("ROICollection", *this);
    }
    catch (std::exception& e) {
        throw SerializationException("Deserialization from ROICollection file '" + filename + "' failed: " + e.what());
    }
    catch (...) {
        throw SerializationException("Deserialization from ROICollection file '" + filename + "' failed (unknown exception).");
    }
}
Example #3
0
GLuint LoadTGA(const char *file_path)				// load TGA file to memory
{
	std::ifstream fileStream(file_path, std::ios::binary);
	if(!fileStream.is_open()) {
		std::cout << "Impossible to open " << file_path << ". Are you in the right directory ?\n";
		return 0;
	}

	GLubyte		header[ 18 ];									// first 6 useful header bytes
	GLuint		bytesPerPixel;								    // number of bytes per pixel in TGA gile
	GLuint		imageSize;									    // for setting memory
	GLubyte *	data;
	GLuint		texture = 0;
	unsigned	width, height;
	float maxAnisotropy = 1.f;

	fileStream.read((char*)header, 18);
	width = header[12] + header[13] * 256;
	height = header[14] + header[15] * 256;

 	if(	width <= 0 ||								// is width <= 0
		height <= 0 ||								// is height <=0
		(header[16] != 24 && header[16] != 32))		// is TGA 24 or 32 Bit
	{
		fileStream.close();							// close file on failure
		std::cout << "File header error.\n";
		return 0;										
	}

	bytesPerPixel	= header[16] / 8;						//divide by 8 to get bytes per pixel
	imageSize		= width * height * bytesPerPixel;	// calculate memory required for TGA data
	
	data = new GLubyte[ imageSize ];
	fileStream.seekg(18, std::ios::beg);
	fileStream.read((char *)data, imageSize);
	fileStream.close();	

	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	if(bytesPerPixel == 3)
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGR, GL_UNSIGNED_BYTE, data);
	else //bytesPerPixel == 4
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);

	//to do: modify the texture parameters code from here
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glGenerateMipmap(GL_TEXTURE_2D);
	glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (GLint)maxAnisotropy);
	//end of modifiable code

	delete []data;

	return texture;						
}
Example #4
0
void Sparse6Writer::doIO()
{
    IntegerMatrix integerMatrix = _graphPointer->getIntegerMatrix();
    // need the undirectedVersion
    integerMatrix.toUndirected();
    vector<pair<unsigned, unsigned> > groups = constructGroups(integerMatrix);

    unsigned numberOfNodes = integerMatrix.getNumberOfNodes();
    unsigned k = ceil(log2(numberOfNodes - 1));

    BitVector bitVector = constructBitvector(groups, k);

    bool last = false;
    bool beforeLast = false;

    if (numberOfNodes >= 2)
    {
        last = integerMatrix.nodeHasEdge(numberOfNodes - 1);
        beforeLast =  integerMatrix.nodeHasEdge(numberOfNodes - 2);
    }
    padUp(bitVector, numberOfNodes, k, last, beforeLast);

    string encodedGraph =  prepareString(bitVector, numberOfNodes);

    // open a filestream
    fstream fileStream(_fileName.c_str(), ios::out);
    // the format is defined so that after the header there is no linebreak
    fileStream << _header << ":"; // need the ':' character to identify s6 format
    fileStream << encodedGraph;
    fileStream.close();
}
Example #5
0
bool LLUpdateDownloader::Implementation::validateDownload(const std::string& filePath)
{
	llifstream fileStream(filePath.c_str(), std::ios_base::in | std::ios_base::binary);
	if(!fileStream)
	{
		LL_INFOS("UpdaterService") << "can't open " << filePath << ", invalid" << LL_ENDL;
		return false;
	}

	std::string hash = mDownloadData["hash"].asString();
	if (! hash.empty())
	{
		char digest[33];
		LLMD5(fileStream).hex_digest(digest);
		if (hash == digest)
		{
			LL_INFOS("UpdaterService") << "verified hash " << hash
									   << " for downloaded " << filePath << LL_ENDL;
			return true;
		}
		else
		{
			LL_WARNS("UpdaterService") << "download hash mismatch for "
									   << filePath << ": expected " << hash
									   << " but computed " << digest << LL_ENDL;
			return false;
		}
	}
	else
	{
		LL_INFOS("UpdaterService") << "no hash specified for " << filePath
								   << ", unverified" << LL_ENDL;
		return true; // No hash check provided.
	}
}
Example #6
0
void TPicturesProject::readGoodDatFile(QFile & file)
{
    file.open(QIODevice::ReadOnly);
    QTextStream fileStream(&file);

    while(!fileStream.atEnd()) {
        QString string(fileStream.readLine());
        QTextStream stringStream(&string, QIODevice::ReadOnly);

        markedPictures.push_back(TMarkedPicture());
        TMarkedPictures::reference currentMarkedPicture = markedPictures.back();

        QString pictureFileName;
        stringStream >> pictureFileName;
        QFileInfo pictureFileInfo(pictureFileName);
        currentMarkedPicture.name = pictureFileInfo.fileName();

        int objectsSize = 0;
        stringStream >> objectsSize;
        for (int i = 0; i < objectsSize; ++i) {
            int left = 0;
            stringStream >> left;
            int top = 0;
            stringStream >> top;
            int width = 0;
            stringStream >> width;
            int height = 0;
            stringStream >> height;
            currentMarkedPicture.objects.push_back(QRect(left, top, width, height));
        }
    }
}
Example #7
0
bool ModelGeometry::loadCachedFile(const std::string& filename) {
    std::ifstream fileStream(filename, std::ifstream::binary);
    if (fileStream.good()) {
        int8_t version = 0;
        fileStream.read(reinterpret_cast<char*>(&version), sizeof(int8_t));
        if (version != CurrentCacheVersion) {
            LINFO("The format of the cached file has changed, deleting old cache");
            fileStream.close();
            FileSys.deleteFile(filename);
            return false;
        }

        int64_t vSize, iSize;
        fileStream.read(reinterpret_cast<char*>(&vSize), sizeof(int64_t));
        fileStream.read(reinterpret_cast<char*>(&iSize), sizeof(int64_t));

        if (vSize == 0 || iSize == 0) {
            LERROR("Error opening file '" << filename << "' for loading cache file");
            return false;
        }

        _vertices.resize(vSize);
        _indices.resize(iSize);

        fileStream.read(reinterpret_cast<char*>(_vertices.data()), sizeof(Vertex) * vSize);
        fileStream.read(reinterpret_cast<char*>(_indices.data()), sizeof(int) * iSize);

        return fileStream.good();
    }
    else {
        LERROR("Error opening file '" << filename << "' for loading cache file");
        return false;
    }
}
Example #8
0
void ProjectManager::saveProject() {
	project["breakpoints"] = breakpoints;

	std::ofstream fileStream(projectFile);
	fileStream << project << std::endl;
	saved = true;
}
Example #9
0
int main(int /*argc*/, char ** /*argv*/) {
	Util::init();
	
	CppUnit::TestResult controller;

	CppUnit::TestResultCollector result;
	controller.addListener(&result);

	CppUnit::BriefTestProgressListener progress;
	controller.addListener(&progress);

	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

	runner.run(controller);

	std::ofstream fileStream("cppunit_results.xml");
	CppUnit::XmlOutputter xmlOutput(&result, fileStream, "UTF-8");
	xmlOutput.write();

	CppUnit::TextOutputter textOutput(&result, std::cout);
	textOutput.write();

	return 0;
}
Example #10
0
void mitk::VtkShaderRepository::LoadShaders()
{
  itk::Directory::Pointer dir = itk::Directory::New();

  std::string dirPath = "./vtk_shader";

  if( dir->Load( dirPath.c_str() ) )
  {
    int n = dir->GetNumberOfFiles();
    for(int r=0;r<n;r++)
    {
      const char *filename = dir->GetFile( r );

      std::string extension = itksys::SystemTools::GetFilenameExtension(filename);

      if(extension.compare(".xml")==0)
      {
        Shader::Pointer element=Shader::New();

        element->SetName(itksys::SystemTools::GetFilenameWithoutExtension(filename));
        std::string filePath = dirPath + std::string("/") + element->GetName() + std::string(".xml");

        SR_INFO(debug) << "found shader '" << element->GetName() << "'";

        std::ifstream fileStream(filePath.c_str());
        element->LoadXmlShader(fileStream);

        shaders.push_back(element);
      }
    }
  }
}
Example #11
0
	std::string loadSource(const std::string &filename, Constants constants)
	{
		static const std::regex includeMatcher("#include[\t ]+\"([a-zA-z\\.]+)\"[\t ]*");
		static const std::regex versionMatcher("#version[\t ]+[0-9]+");
		static const Constants noConstants;
		std::ifstream fileStream(filename.c_str());
		std::stringstream result;
		std::smatch match;
		std::string line;
		std::string path = tiny::utils::fileDirectory(filename);

		if (fileStream.fail())
			throw std::runtime_error("could not open " + filename);

		while (getline(fileStream, line))
		{		
			if (regex_match(line, match, includeMatcher))
				result << loadSource(path + match[1].str(), noConstants);
			else
				result << line << std::endl;

			if (regex_match(line, versionMatcher))
			{
				for (auto &pair: constants)
					result << "#define " << pair.first << " " << pair.second << std::endl;			
			}
		}

		return result.str();
	}
/**
 * @brief Checks if there's an existing ID in the given file
 * @param id ID to check
 * @param file File to check if there's any other ID in
 * @return True if there are others with the same ID.
 */
bool DataInterface::hasSameID(int id, QFile* file)
{
    //Try to open the file
    if(!file->open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::information(QApplication::activeWindow(), "File Open Error", file->errorString());
        return false;
    }

    //Search through and check if the first param of each line (always the ID) is the same as the param here
    QTextStream fileStream(file);
    while(!file->atEnd())
    {
        QString line = fileStream.readLine();
        if(line.split(",").at(0).toInt() == id)
        {
            file->close();
            return true;
        }
    }

    //Otherwise, close and return none found
    file->close();
    return false;
}
Example #13
0
int mergeGraphs(QString fileName1, QString fileName2, ATMProgressIFC *prg) {
    fileName1 = fileName1.split("\n")[0];
    QFile file1(fileName1);

    if (!file1.open(QIODevice::ReadOnly)) {
        return -1;
    }

    QDataStream fileStream1(&file1);
    NarratorGraph *graph1 = new NarratorGraph(fileStream1, prg);
    file1.close();
    fileName2 = fileName2.split("\n")[0];
    QFile file2(fileName2);

    if (!file2.open(QIODevice::ReadOnly)) {
        return -1;
    }

    QDataStream fileStream2(&file2);
    NarratorGraph *graph2 = new NarratorGraph(fileStream2, prg);
    file2.close();
    graph1->mergeWith(graph2);
    delete graph2;
    QFile file(fileName1.remove(".por") + "Merged.por");

    if (!file.open(QIODevice::ReadWrite)) {
        return -1;
    }

    QDataStream fileStream(&file);
    graph1->serialize(fileStream);
    file.close();
    delete graph1;
    return 0;
}
void QgsSearchQueryBuilder::saveQuery()
{
  QSettings s;
  QString lastQueryFileDir = s.value( "/UI/lastQueryFileDir", "" ).toString();
  //save as qqt (QGIS query file)
  QString saveFileName = QFileDialog::getSaveFileName( 0, tr( "Save query to file" ), lastQueryFileDir, "*.qqf" );
  if ( saveFileName.isNull() )
  {
    return;
  }

  if ( !saveFileName.endsWith( ".qqf", Qt::CaseInsensitive ) )
  {
    saveFileName += ".qqf";
  }

  QFile saveFile( saveFileName );
  if ( !saveFile.open( QIODevice::WriteOnly ) )
  {
    QMessageBox::critical( 0, tr( "Error" ), tr( "Could not open file for writing" ) );
    return;
  }

  QDomDocument xmlDoc;
  QDomElement queryElem = xmlDoc.createElement( "Query" );
  QDomText queryTextNode = xmlDoc.createTextNode( txtSQL->toPlainText() );
  queryElem.appendChild( queryTextNode );
  xmlDoc.appendChild( queryElem );

  QTextStream fileStream( &saveFile );
  xmlDoc.save( fileStream, 2 );

  QFileInfo fi( saveFile );
  s.setValue( "/UI/lastQueryFileDir", fi.absolutePath() );
}
bool Settings::ReadFile(const std::string& file) {
	if (file.empty())
		return false;

	this->file = file;
	std::ifstream fileStream(file.c_str(), std::ios_base::in | std::ios_base::binary);

	fileStream.seekg(0, std::ios::end);
	int size = fileStream.tellg();
	fileStream.seekg(0, std::ios::beg);

	if (size == 0) {
	    std::cerr << "Attempt to read \"" << file << "\": File is empty" << std::endl;
	    return false;
	}

    int soundEnabled, noAsteroids = 0;

	if (fileStream.is_open()) {
	    fileStream.read(reinterpret_cast<char*>(&soundEnabled), sizeof(soundEnabled));
	    fileStream.read(reinterpret_cast<char*>(&noAsteroids), sizeof(noAsteroids));

        sound = ((int)(soundEnabled) == 1 ? true : false);
        noInitialAsteroids = (int)noAsteroids;

        fileStream.close();

        return true;
	}

	return false;
}
Example #16
0
void Config::readSettings(const std::string& filename)
{
    std::ifstream fileStream(filename);
    std::string loadInitialFieldFromFile = "no";
    if(fileStream.is_open())
    {
        std::string line;
        while(getline(fileStream, line))
        {
            std::istringstream stringStream(line);
            std::string parameter;
            // If content available
            if(stringStream >> parameter)
            {
                if (parameter[0] == '#')
                {
                    continue;
                }
                else if(parameter == "cell_count")
                {
                    stringStream >> cell_count[0];
                    stringStream >> cell_count[1];
                }
                else if(parameter == "M")
                {
                    stringStream >> M;
                }
void DotSceneLoader::compileResource(const char* fileName, std::map<std::string, std::string>& options) {
	staticObjects.clear();
	dynamicObjects.clear();

	try {
		TiXmlDocument xmlDoc;
		TiXmlElement *xmlRoot;

		xmlDoc.LoadFile(fileName);

		if(xmlDoc.Error()) {
			return;
		}

		xmlRoot = xmlDoc.RootElement();
		if(std::string(xmlRoot->Value()) != "scene") {
			return;
		}

		scene = new Scene(file::getFilename(fileName), manager);
		rootNode = scene->getRoot();

		processScene(xmlRoot);

		scene->createSceneTree();

		std::string outputName = file::getPath(fileName) + "/" + file::getFilename(fileName) + ".scene";
		FileStream fileStream(outputName);
		ResourceBinStream resourceStream(fileStream);
		SceneUtils::write(resourceStream, *manager, scene);
	} catch(...) {
	}

	delete scene;
}
Example #18
0
int main(int argc, char ** argv) {
	Util::init();

	const std::string testPath = (argc > 1) ? std::string(argv[1]) : "";

	CppUnit::TestResult controller;

	CppUnit::TestResultCollector result;
	controller.addListener(&result);

	CppUnit::BriefTestProgressListener progress;
	controller.addListener(&progress);

	CppUnit::TestRunner runner;
	runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());

	runner.run(controller, testPath);

	std::ofstream fileStream("cppunit_results.xml");
	CppUnit::XmlOutputter xmlOutput(&result, fileStream, "UTF-8");
	xmlOutput.write();

	CppUnit::TextOutputter textOutput(&result, std::cout);
	textOutput.write();

	return result.wasSuccessful() ? 0 : 1;
}
Example #19
0
    ArrayBuffer* readPBFile(const std::string& _fileName) {

        std::ifstream fileStream(_fileName.c_str(), std::ifstream::in);

        if(!fileStream.good()) {
            std::cerr << "could not open file " << _fileName << std::endl;
            return NULL;
        }

        int vertexCount = 0;
        fileStream >> vertexCount;

        float* data = new float[vertexCount * 10]; // all files contain 3 pos float, 3 normal floats, 3 color floats and 1 splat size!

        int pos = 0;
        while(fileStream.good() && pos < (vertexCount * 10)) {
            fileStream >> data[pos];
            pos++;
        }

        fileStream.close();

        ArrayBuffer* ab = new ArrayBuffer();
        ab->setData(vertexCount * 10 * sizeof(float), data);
        ab->defineAttribute("aPosition", GL_FLOAT, 3);
        ab->defineAttribute("aNormal", GL_FLOAT, 3);
        ab->defineAttribute("aColor", GL_FLOAT, 3);
        ab->defineAttribute("aSplatSize", GL_FLOAT, 1);

        delete[] data;

        // ab holds a copy of the data on the GPU memory
        return ab;
    }
// Checked: 2011-11-08 (RLVa-1.5.0)
BOOL RlvFloaterStrings::postBuild()
{
	// Set up the UI controls
	m_pStringList = findChild<LLComboBox>("string_list");
	m_pStringList->setCommitCallback(boost::bind(&RlvFloaterStrings::checkDirty, this, true));

	LLUICtrl* pDefaultBtn = findChild<LLUICtrl>("default_btn");
	pDefaultBtn->setCommitCallback(boost::bind(&RlvFloaterStrings::onStringRevertDefault, this));

	// Read all string metadata from the default strings file
	llifstream fileStream(RlvStrings::getStringMapPath(), std::ios::binary); LLSD sdFileData;
	if ( (fileStream.is_open()) && (LLSDSerialize::fromXMLDocument(sdFileData, fileStream)) )
	{
		m_sdStringsInfo = sdFileData["strings"];
		fileStream.close();
	}

	// Populate the combo box
	for (LLSD::map_const_iterator itString = m_sdStringsInfo.beginMap(); itString != m_sdStringsInfo.endMap(); ++itString)
	{
		const LLSD& sdStringInfo = itString->second;
		if ( (!sdStringInfo.has("customizable")) || (!sdStringInfo["customizable"].asBoolean()) )
			continue;
		m_pStringList->add( (sdStringInfo.has("label")) ? sdStringInfo["label"].asString() : itString->first, itString->first);
	}

	refresh();

	return TRUE;
}
Example #21
0
int _tmain(int argc, _TCHAR* argv[])
{
	LoadLibrary("data\\zlib1.dll");
	_MESSAGE("RealPipboyTest is starting");

	gPipboy.init();

	FOResourceManager *resources = FOResourceManager::getSingleton();
	uint64_t hash1 = resources->hash("textures\\clutter\\snowglobes", "");
	uint64_t hash2 = resources->hash("", "snowglobenelisafb_d.dds");
	resources->load("C:\\SteamGames\\steamapps\\Common\\Fallout New Vegas\\Data");
	
	FOResourceStream fileStream("textures\\interface\\icons\\mood\\glow_messages_happy_big.dds");
	UInt64 fileLen = fileStream.GetLength();
	UInt8 *tempBuffer = new UInt8[fileLen];
	fileStream.ReadBuf(tempBuffer, fileLen);
	delete[] tempBuffer;

	gPipboy.makeConnectable(true);

	while (gRunning) {
		gPipboy.update();
	}

	gPipboy.makeConnectable(false);

	return 0;
}
Example #22
0
int main(int argc, char *argv[]) {
  readDictionary();
  size_t tam;
  std::ifstream fileStream(argv[1]);
  if (!fileStream) {
    std::cerr << "ERROR";
    exit(-1);
  }

  while (fileStream >> tam >> letters) {
    std::sort(letters.begin(), letters.end());
    char previous = letters[0];
    static std::string uniqueLetters;
    uniqueLetters.push_back(previous);

    for (char c : letters) {
      if (c != previous) {
        uniqueLetters.push_back(c);
        previous = c;
      }
    }

    std::vector<std::string> candidates = getWords(uniqueLetters, tam);
    std::vector<std::string> wordSquare = findWordSquare(candidates, tam);

    for (std::string s : wordSquare) {
      std::cout << s << std::endl;
    }

    std::cout << std::endl;
  }

  return 0;
}
Example #23
0
BitmapLoadStatus LoadBitmap(const char* Filename, std::vector<std::uint8_t>* DestBuffer,
                            std::uint32_t* Width, std::uint32_t* Height)
{
    std::ifstream fileStream(Filename, std::ios::binary | std::ios::in);

    if (!fileStream) {
        return FILE_NOT_FOUND;
    }

    BitmapFileHeader fileHeader;
    BitmapInfoHeader infoHeader;

    auto status = LoadAndValidateHeaders(fileStream, &fileHeader, &infoHeader);
    if (status != LOAD_SUCCESS) {
        return status;
    }

    status = LoadPixels(fileStream, DestBuffer, fileHeader, infoHeader);
    if (status != LOAD_SUCCESS) {
        return status;
    }

    FlipRowsAndRemovePadding(DestBuffer, infoHeader);

    *Width = infoHeader.Width;
    *Height = infoHeader.Height;

    return LOAD_SUCCESS;
}
Example #24
0
void ShaderParser::parseFile(const std::string& path)
{
    myFilePath = path;
    std::ifstream fileStream(path);
    std::string source((std::istreambuf_iterator<char>(fileStream)), std::istreambuf_iterator<char>());

    parse(source);
}
Example #25
0
	Resource* ImageKey::loadResource(ResourceManager& manager) const {
		std::string textureName = getName();

		FileStream fileStream("resources/images/" + textureName + ".texture");
		ResourceBinStream resourceStream(fileStream);

		return ImageUtils::read(resourceStream, manager);
	}
Example #26
0
bool IO::write( const UTF8String & fileName, const C * object ) {
	std::fstream fileStream( fileName.getData(), std::ios::out | std::ios::binary );
	if ( fileStream.is_open() ) {
		bool result( IO::write( &fileStream, object ) );
		fileStream.close();
		return result;
	} else
		return false;
}
	void DocumentEditorBase::SaveAsPrivateFormat(const ::vl::WString& fileName)
	{/* USER_CONTENT_BEGIN(::demo::DocumentEditorBase) */
		document->SelectAll();
		auto model = document->GetSelectionModel();

		vl::presentation::ModifyDocumentForClipboard(model);
		vl::stream::FileStream fileStream(fileName, vl::stream::FileStream::WriteOnly);
		vl::presentation::SaveDocumentToClipboardStream(model, fileStream);
	}/* USER_CONTENT_END() */
Example #28
0
void FLAT_Utils::stringFromFile(const char *fileName, std::string& contentString)
{
  contentString = "";
  std::string line = "";
  std::ifstream fileStream(fileName, std::ios::in);
  while(getline(fileStream, line))
    contentString += "\n" + line;
  fileStream.close();
}
Example #29
0
		bool File::ReadAllText(WString& text)const
		{
			FileStream fileStream(filePath.GetFullPath(), FileStream::ReadOnly);
			if (!fileStream.IsAvailable()) return false;
			BomDecoder decoder;
			DecoderStream decoderStream(fileStream, decoder);
			StreamReader reader(decoderStream);
			text = reader.ReadToEnd();
			return true;
		}
	void DocumentEditorBase::SaveAsRTF(const ::vl::WString& fileName)
	{/* USER_CONTENT_BEGIN(::demo::DocumentEditorBase) */
		document->SelectAll();
		auto model = document->GetSelectionModel();

		vl::AString rtf;
		vl::presentation::SaveDocumentToRtf(model, rtf);
		vl::stream::FileStream fileStream(fileName, vl::stream::FileStream::WriteOnly);
		fileStream.Write((void*)rtf.Buffer(), rtf.Length());
	}/* USER_CONTENT_END() */