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


C++ FileHeader类代码示例

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


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

示例1: copyFileToNewZip

bool ZipArchive::copyFileToNewZip(CentralDir *cdir, Stream *newZipStream)
{
   // [tom, 1/24/2007] Using the stored compressor allows us to copy the raw
   // data regardless of compression method without having to re-compress it.
   Compressor *comp = Compressor::findCompressor(Stored);
   if(comp == NULL)
      return false;

   if(! mStream->setPosition(cdir->mLocalHeadOffset))
      return false;

   // Copy file header
   // FIXME [tom, 1/24/2007] This will currently not copy the extra fields
   FileHeader fh;
   if(! fh.read(mStream))
      return false;

   cdir->mLocalHeadOffset = newZipStream->getPosition();

   if(! fh.write(newZipStream))
      return false;

   // Copy file data
   Stream *readS = comp->createReadStream(cdir, mStream);
   if(readS == NULL)
      return false;

   bool ret = newZipStream->copyFrom(readS);

   // [tom, 1/24/2007] closeFile() just frees the relevant filters and
   // thus it is safe to call from here.
   closeFile(readS);

   return ret;
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:35,代码来源:zipArchive.cpp

示例2: main

int main(int argc, char** argv)
{
    if (argc != 2)
        die_printf("Usage: %s <sio-file>\n", argv[0]);
    try
    {
        //  Load a CODA stream
        FileInputStream input(argv[1]);
        //  Create a reader
        FileReader r(&input);
        FileHeader* header = r.readHeader();

        // Now let's spit out header info
        std::cout << ". nl: " << header->getNumLines() << std::endl;
        std::cout << ". ne: " << header->getNumElements() << std::endl;
        std::cout << ". et: " << header->getElementTypeAsString() << std::endl;
        std::cout << ". es: " << header->getElementSize() << std::endl;

        printUserData(header);
    }
    catch (Exception& e)
    {
        std::cout << "Caught exception: " << e.getMessage() << std::endl;
        std::cout << "Trace:" << std::endl << e.getTrace() << std::endl;
    }
}
开发者ID:adam-beauchamp,项目名称:coda-oss,代码行数:26,代码来源:imdmphdr.cpp

示例3: EasyEncrypt

// 文件加密函数
// 这个函数有点长,但是基本上都是检错的代码。逻辑还是很清晰的。
errno_t EasyEncrypt(const string& inFilename, const string& outFilename, const string& key)
{
    LOGPOS();

    FileReader fileReader;
    FilePath inFilePath(inFilename);
    if (fileReader.Open(inFilePath.value()) != CPT_OK) {
        LOGW("Open file %s failed!", inFilePath.value().c_str());
        return CPT_ERROR;
    }

    Encrypt encrypt;
    if (encrypt.SetReader(dynamic_cast<Reader*>(&fileReader)) != CPT_OK) {
        LOGW("Encrypt Set Reader failed");
        return CPT_ERROR;
    }

    FileHeader *fileHeader = encrypt.GenrHeader();
    if (fileHeader == NULL) {
        LOGW("Generate file header failed!");
        return CPT_ERROR;
    }

    fileHeader->SetFormat(inFilePath.Extension());

    if (encrypt.EncryptHeader(key.c_str(), key.length()) != CPT_OK) {
        LOGW("Encrypt file header failed");
        return CPT_ERROR;
    }

    FileWriter writer;
    if (writer.Open(outFilename) != CPT_OK) {
        LOGW("Create file %s failed!", outFilename.c_str());
        return CPT_ERROR;
    }

    if (encrypt.SetWriter(dynamic_cast<Writer*>(&writer)) != CPT_OK) {
        LOGW("encrypt set writer failed!");
        return CPT_ERROR;
    }

    if (encrypt.WriteHeader() != CPT_OK) {
        LOGW("Encrypt write header failed!");
        return CPT_ERROR;
    }
    
    int err = encrypt.PreEncrypt();
    ASSERT(err == CPT_OK);

    if (encrypt.DoEncrypt(key.c_str(), key.length()) != CPT_OK) {
        LOGW("Encrypt encrypt failed!");
        return CPT_ERROR;
    }

    err = encrypt.PostEncrypt();
    ASSERT(err == CPT_OK);

    return CPT_OK;
}
开发者ID:huangaming,项目名称:libcryptocpp,代码行数:61,代码来源:Crypto.cpp

示例4: Update

/*
 * Update the file with new FileHeader information
 */
bool FileHeaderUpdater::Update(std::ofstream& os, FileHeader& updateHdr, FileHeader& currentHdr)
{
	// There is nothing at this time to update in the FileHeader
	// Move on to the GenericDataHeader

	GenericDataHeaderUpdater genUpdater;
	return genUpdater.Update(os, *updateHdr.GetGenericDataHdr(), *currentHdr.GetGenericDataHdr());
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例5: FileHeader

void GenericFileWriterTest::testCreation()
{
    FileHeader* fHdr = new FileHeader();
    fHdr->SetFilename("generic_file_writer");
    GenericFileWriter w(fHdr);
	CPPUNIT_ASSERT(1);
    delete fHdr;
}
开发者ID:einon,项目名称:affymetrix-power-tools,代码行数:8,代码来源:GenericFileWriterTest.cpp

示例6: AddStandardGenericDataHeader

void TestFileGenerator::WriteOutGenericDATDataFileNoGrid()
{
	GenericDataHeader gdh;
	AddStandardGenericDataHeader(gdh);

	// Fill the DataGroupHeader
	DataGroupHeader dch;
	dch.SetName(L"First Data Cube");

	// Fill the DataSetHeader
	DataSetHeader dph;
	dph.SetName(L"acquired data");
	ParameterNameValueType nvt;
	nvt.SetName(L"Scanner");
	nvt.SetValueText(L"M10");
	dph.AddNameValParam(nvt);
	nvt.SetName(L"Pixel Size");
	nvt.SetValueFloat(0.051f);
	dph.AddNameValParam(nvt);

	dph.AddColumn(UShortColumn(L"Pixel"));

	int32_t rows = 100;
	dph.SetRowCnt(rows);

	dch.AddDataSetHdr(dph);

	// Set the FileHeader
	FileHeader fh;
	fh.SetFilename("test.file.data_dat");
	fh.SetGenericDataHdr(gdh);
	fh.AddDataGroupHdr(dch);

	// Create the generic file writer
	GenericFileWriter gfWriter(&fh);
	gfWriter.WriteHeader();

	DataGroupWriterIt dcwBegin, dcwEnd;
	gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd);

	DataGroupWriter d = *dcwBegin;
	dcwBegin->WriteHeader();

	DataSetWriterIt dpwBegin, dpwEnd;
	dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd);

	dpwBegin->WriteHeader();

	// Write out the data
	for( int32_t i=0; i < rows; ++i )
	{
		u_int16_t value = (u_int16_t)(i*10+i);
		dpwBegin->Write(value);
	}

	dpwBegin->UpdateNextDataSetOffset();
	dcwBegin->Close();
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例7: WriteGenericDataHdr

void FileHeaderWriter::WriteGenericDataHdr(std::ofstream &os, FileHeader &g)
{
    GenericDataHeaderWriter writer;

		// Check if a file ID has been assign, if not assign one.
		if (g.GetGenericDataHdr()->GetFileId().length() == 0)
			g.GetGenericDataHdr()->SetFileId(AffymetrixGuid::GenerateNewGuid());

    writer.Write(os, *(g.GetGenericDataHdr()));
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例8: EasyDecrypt

errno_t EasyDecrypt(const string& filename, const string& key, string *outFilename)
{
    LOGPOS();

    FilePath inFilePath(filename);
    FileReader reader;
    if (reader.Open(inFilePath.value()) != CPT_OK) {
        LOGW("Open file %s failed!", inFilePath.value().c_str());
        return CPT_ERROR;
    }

    Decrypt decrypt;
    if (decrypt.SetReader(&reader) != CPT_OK) {
        LOGW("Decrypt set reader failed!");
        return CPT_ERROR;
    }

    if (decrypt.LoadHeader() != CPT_OK) {
        LOGW("Decrypt load header failed!");
        return CPT_ERROR;
    }

    FileHeader *fileHeader = decrypt.DecryptHeader(key.c_str(), key.length());
    if (fileHeader == NULL) {
        LOGW("LoadHeader error");
        return CPT_ERROR;
    }

    FilePath outFilePath = inFilePath.ReplaceExtension(fileHeader->GetFormat());
    *outFilename = outFilePath.value();
    FileWriter writer;
    if (writer.Open(outFilePath.value()) != CPT_OK) {
        LOGW("Create file %s failed!", outFilePath.value().c_str());
        return CPT_ERROR;
    }

    if (decrypt.SetWriter(dynamic_cast<Writer*>(&writer)) != CPT_OK) {
        LOGW("Decrypt set writer failed!");
        return CPT_ERROR;
    }

    int err = decrypt.PreDecrypt();
    ASSERT(err == CPT_OK);

    if (decrypt.DoDecrypt(key.c_str(), key.length())) {
        LOGW("Decrypt decrypt file failed!");
        return CPT_ERROR;
    }

    err = decrypt.PostDecrypt();
    ASSERT(err == CPT_OK);

    return CPT_OK;
}
开发者ID:huangaming,项目名称:libcryptocpp,代码行数:54,代码来源:Crypto.cpp

示例9:

SerialNum
IndexReadUtilities::readSerialNum(const vespalib::string &dir)
{
    const vespalib::string fileName = IndexDiskLayout::getSerialNumFileName(dir);
    Fast_BufferedFile file;
    file.ReadOpen(fileName.c_str());

    FileHeader fileHeader;
    fileHeader.readFile(file);
    if (fileHeader.hasTag(IndexDiskLayout::SerialNumTag)) {
        return fileHeader.getTag(IndexDiskLayout::SerialNumTag).asInteger();
    }
    return 0;
}
开发者ID:songhtdo,项目名称:vespa,代码行数:14,代码来源:indexreadutilities.cpp

示例10: FileHeaderTest

void CDFDataTest::FileHeaderTest()
{
	// Put something into the header.
	data->SetArrayCols(45);

	// Get the header.
	FileHeader* fh = data->GetFileHeader();
	CPPUNIT_ASSERT(fh);

	// Try to read the thing from the header.
	ParameterNameValueType pvt;
	CPPUNIT_ASSERT(fh->GetGenericDataHdr()->FindNameValParam(CDF_COLS_PARAM, pvt));
	CPPUNIT_ASSERT(pvt.GetValueUInt32() == 45);
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例11: CPPUNIT_ASSERT_NO_THROW

void CDFFileReaderTest::ReadSmallCDFFileBasicTest()
{
	CDFData data;
	CDFFileReader reader;
	CPPUNIT_ASSERT_NO_THROW(reader.SetFilename(SMALL_CDF_FILE));
	CPPUNIT_ASSERT_NO_THROW(reader.Read(data));

	CPPUNIT_ASSERT(data.GetFilename() == SMALL_CDF_FILE);

	FileHeader* fh = data.GetFileHeader();
	u_int32_t pos = fh->GetFirstDataGroupFilePos();
	CPPUNIT_ASSERT(pos == 0x1BD);
	CPPUNIT_ASSERT(data.GetProbeSetCnt() == 10);
	CPPUNIT_ASSERT(data.GetArrayRows() == 10*2);
	CPPUNIT_ASSERT(data.GetArrayCols() == 11);
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例12: ReadAll

/*
 * Reads all the DataGroupHeaders in a file and all information for each DataSetHeader in every DataGroup.
 */
void DataGroupHeaderReader::ReadAll(std::ifstream& fileStream, FileHeader& fh, u_int32_t dataGroupCnt)
{
	// Get the first data group offset
	u_int32_t nextDataGroupFilePos = fh.GetFirstDataGroupFilePos();

	for (u_int32_t i = 0; i < dataGroupCnt; ++i)
	{
		// Read the DataGroupHeader
		DataGroupHeader dch;

		// Move to the indicated position in the file
		fileStream.seekg(nextDataGroupFilePos, std::ios_base::beg);

		nextDataGroupFilePos = Read(fileStream, dch);
		fh.AddDataGroupHdr(dch);
	}
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例13: xmlMetadata

void CPHDWriter::writeMetadata(size_t vmbSize,
                               size_t cphdSize)
{
    const std::string xmlMetadata(CPHDXMLControl().toXMLString(mMetadata));

    FileHeader header;
    header.set(xmlMetadata.size(), vmbSize, cphdSize);

    mFile.write(header.toString().c_str(), header.size());
    mFile.write("\f\n", 2);
    mFile.write(xmlMetadata.c_str(), xmlMetadata.size());
    mFile.write("\f\n", 2);

    // Pad bytes
    char zero = 0;
    for (sys::Off_T ii = 0; ii < header.getPadBytes(); ++ii)
    {
        mFile.write(&zero, 1);
    }
}
开发者ID:BSteine,项目名称:six-library,代码行数:20,代码来源:CPHDWriter.cpp

示例14: method

Stream *ZipArchive::openFileForRead(const CentralDir *fileCD)
{
   if(mMode != Read && mMode != ReadWrite)
      return NULL;

   if((fileCD->mInternalFlags & (CDFileDeleted | CDFileOpen)) != 0)
      return NULL;

   Stream *stream = mStream;

   if(fileCD->mInternalFlags & CDFileDirty)
   {
      // File is dirty, we need to read from the temporary file
      for(S32 i = 0;i < mTempFiles.size();++i)
      {
         if(mTempFiles[i]->getCentralDir() == fileCD)
         {
            // Found the temporary file
            if(! mTempFiles[i]->rewind())
            {
               if(isVerbose())
                  Con::errorf("ZipArchive::openFile - %s: %s is dirty, but could not rewind temporary file?", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
               return NULL;
            }

            stream = mTempFiles[i];
            break;
         }
      }

      if(stream == mStream)
      {
         if(isVerbose())
            Con::errorf("ZipArchive::openFile - %s: %s is dirty, but no temporary file found?", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
         return NULL;
      }
   }
   else
   {
      // Read from the zip file directly
      if(! mStream->setPosition(fileCD->mLocalHeadOffset))
      {
         if(isVerbose())
            Con::errorf("ZipArchive::openFile - %s: Could not locate local header for file %s", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
         return NULL;
      }

      FileHeader fh;
      if(! fh.read(mStream))
      {
         if(isVerbose())
            Con::errorf("ZipArchive::openFile - %s: Could not read local header for file %s", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
         return NULL;
      }
   }

   Stream *attachTo = stream;
   U16 compMethod = fileCD->mCompressMethod;

   if(fileCD->mFlags & Encrypted)
   {
      if(fileCD->mCompressMethod == AESEncrypted)
      {
         // [tom, 1/19/2007] Whilst AES support does exist, I'm not including it in TGB
         // to avoid having to deal with crypto export legal issues.
         Con::errorf("ZipArchive::openFile - %s: File %s is AES encrypted, but AES is not supported in this version.", mFilename ? mFilename : "<no filename>", fileCD->mFilename.c_str());
      }
      else
      {
         ZipCryptRStream *cryptStream = new ZipCryptRStream;
         cryptStream->setPassword(DEFAULT_ZIP_PASSWORD);
         cryptStream->setFileEndPos(stream->getPosition() + fileCD->mCompressedSize);
         if(! cryptStream->attachStream(stream))
         {
            delete cryptStream;
            return NULL;
         }

         attachTo = cryptStream;
      }
   }

   Compressor *comp = Compressor::findCompressor(compMethod);
   if(comp == NULL)
   {
      if(isVerbose())
         Con::errorf("ZipArchive::openFile - %s: Unsupported compression method (%d) for file %s", mFilename ? mFilename : "<no filename>", fileCD->mCompressMethod, fileCD->mFilename.c_str());
      return NULL;
   }

   return comp->createReadStream(fileCD, attachTo);
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:92,代码来源:zipArchive.cpp

示例15: WriteDataGroupCnt

void FileHeaderWriter::WriteDataGroupCnt(std::ofstream &os, FileHeader &g)
{
	FileOutput::WriteInt32(os, g.GetDataGroupCnt());
}
开发者ID:,项目名称:,代码行数:4,代码来源:


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