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


C++ writeFile函数代码示例

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


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

示例1: main

int main()
{
    std::stringstream a_foldername;
    a_foldername.str( std::string() );
    a_foldername.clear();
    a_foldername << "calibrationData" << "/" << getDate() << "_" << getTime() << "/";
    std::cout << "Folder: " << a_foldername.str() << std::endl;

    std::stringstream a_filename;
    a_filename.str( std::string() );
    a_filename.clear();
    a_filename << "pointsGen.csv";
    std::cout << "File: " << a_filename.str() << std::endl;

    std::string a_filepath = writeFile( a_foldername.str(), a_filename.str() );

    readFile( a_filepath );

    return 0;
}
开发者ID:meilu2two,项目名称:apps,代码行数:20,代码来源:main.cpp

示例2: emptyTreeWidget

bool LOCACC::deleteScreen(QTreeWidgetItem *currentItem)
{
    QString screenId = currentItem->text(0);
    QJsonArray locArray = m_jsonMasterObj["locAccData"].toArray();
    QJsonObject tempObj;
    for(int i = 0 ; i < locArray.count() ; i++)
    {
        tempObj = locArray.at(i).toObject();
        if(tempObj["id"] == screenId)
        {
            locArray.removeAt(i);
            break;
        }
    }
    m_jsonMasterObj["locAccData"] = locArray;
    currentItem->parent()->removeChild(currentItem);
    emptyTreeWidget(currentItem);
    writeFile();
    return true;
}
开发者ID:vihangpatel,项目名称:WatchDog2,代码行数:20,代码来源:locacc.cpp

示例3: main

int main(int argc, char* argv[])
{
    POINT** points = NULL;

    if(argc > 1)
    {
        points = readFile(argv[1]);
        if(points != NULL)
        {
            display(points,12);
            polygon(points, 12);
            display(points, 12);

            writeFile(points, 13, argv[1]);
            destroyPoint(points, 13);
        }
    }

    return 0;
}
开发者ID:Orcrist1,项目名称:Programming-Technique,代码行数:20,代码来源:main.c

示例4: tr

void GaussianBeamWindow::saveFile(const QString& path)
{
	QSettings settings;
	QString fileName = path;
	QString dir = settings.value("GaussianBeamWindow/lastDirectory", "").toString();

	if (fileName.isNull())
		fileName = QFileDialog::getSaveFileName(this, tr("Save File"), dir, "*.xml");
	if (fileName.isEmpty())
		return;
	if (!fileName.endsWith(".xml"))
		fileName += ".xml";

	if (writeFile(fileName))
	{
		setCurrentFile(fileName);
		statusBar()->showMessage(tr("File") + " " + QFileInfo(fileName).fileName() + " " + tr("saved"));
		settings.setValue("GaussianBeamWindow/lastDirectory", QFileInfo(fileName).path());
	}
}
开发者ID:lrunze,项目名称:MyDocuments,代码行数:20,代码来源:GaussianBeamWindow.cpp

示例5: kTermWriteFile

static void kTermWriteFile(char *name)
{
	FILE f;
	unsigned char buffer[512] = "Let's write a file";
	f=openFile(name,'w');
	if(f.flags == FS_FILE_INVALID){
		print("\r\nFile not found...");
		closeFile(&f);
		return;
	} else if (f.flags== FS_DIRECTORY){
		print("\r\n%s is a directory");
		closeFile(&f);
		return;
	}

	if(writeFile(&f,buffer,19) > 0)
		print("Writing complete\r\n");

	closeFile(&f);
}
开发者ID:FabrizioPerria,项目名称:JackOS,代码行数:20,代码来源:kTerm.c

示例6: writeFile

int ShibeTranslator::saveToFile(const QString &fileName)
{
	QStringList resultList;
	resultList.append(getMapList(&buttonMap,"Button_"));
	resultList.append(getMapList(&labelMap,"Label_"));
	resultList.append(getMapList(&checkBoxMap,"CheckBox_"));
	resultList.append(getMapList(&groupBoxMap,"GroupBox_"));
	resultList.append(getMapList(&spinBoxMap,"SpinBox_"));
	resultList.append(getMapList(&stringMap,"String_"));
	if(resultList.isEmpty())return 1;
	resultList.sort();
	QFile writeFile(fileName);
	if(writeFile.open(QIODevice::WriteOnly|QIODevice::Truncate))
	{
		writeFile.write(QString(resultList.join("\r\n")+"\r\n").toUtf8());
		writeFile.close();
		return 0;
	}
	return 2;
}
开发者ID:TraderShibe,项目名称:TraderShibe,代码行数:20,代码来源:Shibetranslator.cpp

示例7: main

int main(int argc, const char * argv[]){
    if (argc!=4) {
        std::cout<<"patch command parameter:\n oldFileName diffFileName outNewFileName\n";
        return 0;
    }
    const char* oldFileName=argv[1];
    const char* diffFileName=argv[2];
    const char* outNewFileName=argv[3];
    std::cout<<"old :\"" <<oldFileName<< "\"\ndiff:\""<<diffFileName<<"\"\nout :\""<<outNewFileName<<"\"\n";
    clock_t time0=clock();
    {
        std::vector<TByte> diffData; readFile(diffData,diffFileName);
        const TUInt diffFileDataSize=(TUInt)diffData.size();
        TUInt kNewDataSizeSavedSize=-1;
        const hpatch_StreamPos_t _newFileDataSize=readSavedSize(diffData,&kNewDataSizeSavedSize);
        const TUInt newDataSize=(TUInt)_newFileDataSize;
        if (newDataSize!=_newFileDataSize) exit(1);

        std::vector<TByte> oldData; readFile(oldData,oldFileName);
        const TUInt oldDataSize=(TUInt)oldData.size();

        std::vector<TByte> newData;
        newData.resize(newDataSize);
        TByte* newData_begin=0; if (!newData.empty()) newData_begin=&newData[0];
        const TByte* oldData_begin=0; if (!oldData.empty()) oldData_begin=&oldData[0];
        clock_t time1=clock();
        if (!patch(newData_begin,newData_begin+newDataSize,oldData_begin,oldData_begin+oldDataSize,
                   &diffData[0]+kNewDataSizeSavedSize, &diffData[0]+diffFileDataSize)){
            std::cout<<"  patch run error!!!\n";
            exit(3);
        }
        clock_t time2=clock();
        writeFile(newData,outNewFileName);
        std::cout<<"  patch ok!\n";
        std::cout<<"oldDataSize : "<<oldDataSize<<"\ndiffDataSize: "<<diffData.size()<<"\nnewDataSize : "<<newDataSize<<"\n";
        std::cout<<"\npatch   time:"<<(time2-time1)*(1000.0/CLOCKS_PER_SEC)<<" ms\n";
    }
    clock_t time3=clock();
    std::cout<<"all run time:"<<(time3-time0)*(1000.0/CLOCKS_PER_SEC)<<" ms\n";
    return 0;
}
开发者ID:snowdream,项目名称:android-diffpatch,代码行数:41,代码来源:native_patch.cpp

示例8: getCachedDirectory

/*
 * Create a file on the disk
 */
bool Directory::createFile(string path, string name, string &data) {
	if (!initialised) throw std::runtime_error("Directory not Initialised");
	if (isPathNameLegal(path) && isNameLegal(name)) {
		// check the path is valid
		int directoryNode = directoryTree->getPathNode(path);
		if (directoryNode < 0) {
			cout << "path " << path << " is invalid" << endl;
			return false;
		}
		// cache the directory (path) if it is not already cached
		int directoryNodeCache = getCachedDirectory(directoryNode);
		// check the filename does not already exist
		if (cachedDirectory[directoryNodeCache]->cache.count(name) > 0) {
			cout << "file/Directory " << name << " already exists" << endl;
			freeCachedDirectory(directoryNodeCache);
			return false;
		}
		// create an INode
		int fileBlock = freeBlockList->getBlock();
		int fileNode = iNodeList->writeNewINode(false,data.length(),fileBlock);
		iNodeList->lockINode(fileNode);
		// write the file
		if (!writeFile(fileNode,data)) {
			iNodeList->unLockINode(fileNode);
			freeCachedDirectory(directoryNodeCache);
			return false;
		}
		// add the file to the directory
		iNodeList->lockINode(directoryNode);
		cachedDirectory[directoryNodeCache]->cache.insert({name,fileNode});
		// write the directory
		cachedDirectory[directoryNodeCache]->writeCachedDirectory();
		iNodeList->unLockINode(directoryNode);
		iNodeList->unLockINode(fileNode);
		freeCachedDirectory(directoryNodeCache);
		return true;
	} else {
		cout << "Path or filename not legal" << endl;
		return false;
	}
}
开发者ID:WilliamAlcock,项目名称:CourseWork,代码行数:44,代码来源:Directory.cpp

示例9: alsa_audio_start

static void* alsa_audio_start(void *aux)
{
	audio_fifo_t *af = aux;
	snd_pcm_t *h = NULL;
	int c;
	int cur_channels = 0;
	int cur_rate = 0;

	audio_fifo_data_t *afd;

	for (;;) {
		afd = audio_get(af);

		if (!h || cur_rate != afd->rate || cur_channels != afd->channels) {
			if (h) snd_pcm_close(h);

			cur_rate = afd->rate;
			cur_channels = afd->channels;

            h = alsa_open("default", cur_rate, cur_channels);

            if (!h) {
                fprintf(stderr, "Unable to open ALSA device (%d channels, %d Hz), dying\n",
                        cur_channels, cur_rate);
                exit(1);
            }
		}

		c = snd_pcm_wait(h, 1000);

		if (c >= 0)
			c = snd_pcm_avail_update(h);

		if (c == -EPIPE)
			snd_pcm_prepare(h);

        snd_pcm_writei(h, afd->samples, afd->nsamples);
        writeFile( &afd->samples );
        zfree(afd);
	}
}
开发者ID:raphui,项目名称:wMusic,代码行数:41,代码来源:alsa-audio.c

示例10: while

void Huffman::compressHuffmanToFile() {

	std::cout << "- Huffman Code Compressed To ASCII. Saved To A New File\n\n"; // shhh.. not yet really. But it's going to happen below.

	// pad the huffman code to create chunks of equal size (8-bits) - Reason... CPU reads min of a byte (8-bits)
	while (huffmanCode.size() % 8 != 0) {
		huffmanCode.append("0");
		padding++;
	}

	std::string compressedCode;
	std::stringstream sstream(huffmanCode);
	std::bitset<8> byte;

	bool innerControl = true; // I got none.
	int i = 0; // this and the inner while loop is for the output of bit codes in 8 bit chunks

	std::cout << std::right << std::setw(15) << "Character";
	std::cout << " | ASCII Code" << std::endl;
	
	while (sstream) { // this would add incorrect character at the end w/o the additional padding. Could've used .good() as well
		sstream >> byte;
		char c = char(byte.to_ulong());
		compressedCode += c;
		std::cout << std::right << std::setw(11) << " "; // this is just to pad the space on the left hand side
		std::cout << c;
		while (innerControl) {
			std::cout << std::setw(15) << huffmanCode.substr(i, 8) << std::endl;
			i += 8;
			innerControl = false;
		}
		innerControl = true;
	}

	compressedCode.pop_back(); // this is to cut off the extra NUL (\0) at the end (Tip for whoever comes by this CA - Notepad++ points out NULs in text files)

	// write out the compressed code to file
	writeFile(compressedCode, "CompressedHuffman.txt");

	std::cout << std::right << std::setw(6) << " " << "Output To File: " << compressedCode << "\n\n";
}
开发者ID:CobraHiss,项目名称:Y3_ADS2_CA1,代码行数:41,代码来源:Huffman.cpp

示例11: datas

void DataManager::generateXmlFile(){
    XmlTree dataTree;
    dataTree.setTag("QLT_Genome_Data");

    dataTree.push_back(XmlTree("datapath","./data/exons/"));
    
    XmlTree datas("datasets","");
    for(int i=0;i<23;i++){
        XmlTree dataset("dataset","");
        dataset.setAttribute("id", i);
        dataset.push_back( XmlTree("title","Chromosome "+toString(i+1)) );
        dataset.push_back( XmlTree("map","exons."+toString(i+1)+".locations") );
        dataset.push_back( XmlTree("bases","exons."+toString(i+1)+".bases") );
        datas.push_back( dataset );
    }
    dataTree.push_back( datas );

    DataTargetPathRef f = writeFile( getAssetPath( "QLT_Genome_Data.xml" ), true );
    dataTree.write( f );
    
}
开发者ID:saynono,项目名称:QLT_GenomeLaser,代码行数:21,代码来源:DataManager.cpp

示例12: memset

void Module::genhdrfile()
{
    OutBuffer hdrbufr;
    hdrbufr.doindent = 1;

    hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
    hdrbufr.writenl();

    HdrGenState hgs;
    memset(&hgs, 0, sizeof(hgs));
    hgs.hdrgen = 1;

    toCBuffer(&hdrbufr, &hgs);

    // Transfer image to file
    hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
    hdrbufr.data = NULL;

    ensurePathToNameExists(Loc(), hdrfile->toChars());
    writeFile(loc, hdrfile);
}
开发者ID:D-Programming-microD,项目名称:GDC,代码行数:21,代码来源:hdrgen.c

示例13: uncompile

int ShaderD3D::prepareSourceAndReturnOptions(std::stringstream *shaderSourceStream)
{
    uncompile();

    int additionalOptions = 0;

    const std::string &source = mData.getSource();

#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
    if (gl::DebugAnnotationsActive())
    {
        std::string sourcePath = getTempPath();
        writeFile(sourcePath.c_str(), source.c_str(), source.length());
        additionalOptions |= SH_LINE_DIRECTIVES | SH_SOURCE_PATH;
        *shaderSourceStream << sourcePath;
    }
#endif

    *shaderSourceStream << source;
    return additionalOptions;
}
开发者ID:70599,项目名称:Waterfox,代码行数:21,代码来源:ShaderD3D.cpp

示例14: writePeerCerts

static void writePeerCerts(
	CFArrayRef			peerCerts,
	const char			*fileBase)
{
	CFIndex numCerts;
	SecCertificateRef certRef;
	CFIndex i;
	char fileName[100];
	
	if(peerCerts == NULL) {
		return;
	}
	numCerts = CFArrayGetCount(peerCerts);
	for(i=0; i<numCerts; i++) {
		sprintf(fileName, "%s%02d.cer", fileBase, (int)i);
		certRef = (SecCertificateRef)CFArrayGetValueAtIndex(peerCerts, i);
		writeFile(fileName, SecCertificateGetBytePtr(certRef),
			SecCertificateGetLength(certRef));
	}
	printf("...wrote %lu certs to fileBase %s\n", numCerts, fileBase);
}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:21,代码来源:sslServer.cpp

示例15: saveFile

void
saveFile(void)
{
	int i, len;
	word *pTable;

	writeFile("dccs", 4);					/* Signature */				
	writeFileShort(numKeys);				/* Number of keys */
	writeFileShort((short)(numKeys * C));	/* Number of vertices */
	writeFileShort(PATLEN);					/* Length of key part of entries */
	writeFileShort(SYMLEN);					/* Length of symbol part of entries */

	/* Write out the tables T1 and T2, with their sig and byte lengths in front */
	writeFile("T1", 2);						/* "Signature" */
	pTable = readT1();
	len = PATLEN * 256;
	writeFileShort(len * sizeof(word));
	for (i=0; i < len; i++)
	{
		writeFileShort(pTable[i]);
	}
	writeFile("T2", 2);
	pTable = readT2();
	writeFileShort(len * sizeof(word));
	for (i=0; i < len; i++)
	{
		writeFileShort(pTable[i]);
	}

	/* Write out g[] */
	writeFile("gg", 2);			  			/* "Signature" */
	pTable = readG();
	len = (short)(numKeys * C);
	writeFileShort(len * sizeof(word));
	for (i=0; i < len; i++)
	{
		writeFileShort(pTable[i]);
	}

	/* Now the hash table itself */
	writeFile("ht ", 2);			  			/* "Signature" */
	writeFileShort(numKeys * (SYMLEN + PATLEN + sizeof(word)));	/* byte len */
	for (i=0; i < numKeys; i++)
	{
		writeFile((char *)&keys[i], SYMLEN + PATLEN);
	}
}
开发者ID:Nico01,项目名称:dcc,代码行数:47,代码来源:makedsig.c


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