コード例 #1
0
ファイル: eps.cpp プロジェクト: innovatelogic/ilogic-vm
BMMRES
	BitmapIO_EPS::GetImageInfoDlg (HWND hWnd, BitmapInfo *info, 
	const TCHAR *filename)
{
	free (iFilename);
	iFilename = NULL;

	if (filename) {
		iFilename = (TCHAR *) malloc ((_tcslen(filename)+1)*sizeof(TCHAR));
		if (iFilename)
			_tcscpy (iFilename, filename);
		ReadHeader (iFilename);
	} else if (info->Name ()) {
		iFilename = (TCHAR *) 
			malloc ((_tcslen(info->Name ())+1)*sizeof(TCHAR));
		if (iFilename)
			_tcscpy (iFilename, info->Name ());
		ReadHeader (iFilename);
	} else {
		MessageBox (hWnd, _T("EPS GetImageInfoDlg called with no file name"),
			_T("EPS Plugin"), MB_ICONINFORMATION);
		return BMMRES_FILENOTFOUND;
	}

	DialogBoxParam (hResource,
		MAKEINTRESOURCE (IDD_INFO_DIALOG),
		hWnd,
		ImageInfoDlg,
		(LPARAM) this);

	return BMMRES_SUCCESS;
}
コード例 #2
0
ファイル: wig2gif.c プロジェクト: dellagustin/mp31
static PSBOOK *ReadAllOldAtoms(char *bok_filename,int *NumOfWav)
 {      /* Wczytanie wszystkich zestawow ksiazek (usredniona mapa Wignera) */
   extern unsigned long NumberOfAllWaveForms;
   int i,k,NumberOfBloks,j,num_of_wav;
   PSBOOK *book=NULL;
   FILE *plik=NULL;
   HEADER head;			/* Funkcja zwraca globalna liczbe atomow */
   ATOM atom;
   float df;

   if((NumberOfBloks=LicznikKsiazek(bok_filename))==-1)
     ERROR("Problemy z odczytem struktury ksiazki !");

   num_of_wav=(int)NumberOfAllWaveForms;
   if((book=(PSBOOK *)malloc((unsigned)num_of_wav*sizeof(PSBOOK)))==NULL)
     ERROR("Brak pamieci (ReadAllAtoms) !");

   if((plik=fopen(bok_filename,"rb"))==NULL)
     ERROR("Problemy przy otwarciu zbioru !\n");

    if(ReadHeader(&head,plik)==-1)
     ERROR("Blad czytania naglowka (ReadAllAtoms) !");

    fseek(plik,0L,SEEK_SET);
    df=2.0F*M_PI/(float)(head.signal_size);

    Ec=E0=0.0F;
    for(i=0,k=0 ; i<NumberOfBloks ; i++)
     {
       if(ReadHeader(&head,plik)==-1)
	 ERROR("Blad czytania naglowka (ReadAllAtoms) !");

       if(head.signal_size!=DimBase)                /* W przypadku niezgodnosci */
	 if(prn==ON)
	   fprintf(stderr,"UWAGA ! Niezgodnosc rozmiaru bazy (%d)"
		   " i analizowanego naglowka (%d)\n",
		   DimBase,head.signal_size);

       E0+=head.signal_energy;
       for(j=0 ; j<head.book_size ; j++)
	{
	  if(ReadAtom(&atom,plik)==-1)
	    ERROR("Blad czytania atomu (ReadAllAtoms) !");

	  book[k].s=(float)(1<<(atom.octave));
	  book[k].t=(float)atom.position;
	  book[k].w=atom.modulus;
	  book[k].f=df*(float)atom.frequency;
	  book[k].amplitude=atom.amplitude;
	  Ec+=SQR(atom.modulus);
	  k++;
	}
     }
   fclose(plik);
   *NumOfWav=num_of_wav;
   return book;
 }
コード例 #3
0
    //----------------------------------------------------------------------------
    //----------------------------------------------------------------------------
    void CSAnimProvider::ReadSkinnedAnimationFromFile(StorageLocation in_location, const std::string& in_filePath, const ResourceProvider::AsyncLoadDelegate& in_delegate, const SkinnedAnimationSPtr& out_resource) const
    {
        IBinaryInputStreamUPtr stream = Application::Get()->GetFileSystem()->CreateBinaryInputStream(in_location, in_filePath);

        u32 numFrames = 0;
        s32 numSkeletonNodes = 0;
        if(ReadHeader(stream, in_filePath, out_resource, numFrames, numSkeletonNodes) == false)
        {
            CS_LOG_ERROR("Failed to read header in anim: " + in_filePath);
            out_resource->SetLoadState(Resource::LoadState::k_failed);
            if(in_delegate != nullptr)
            {
                Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept
                {
                    in_delegate(out_resource);
                });
            }
            return;
        }
        
        ReadAnimationData(stream, numFrames, numSkeletonNodes, out_resource);
        
        out_resource->SetLoadState(Resource::LoadState::k_loaded);
        
        if(in_delegate != nullptr)
        {
            Application::Get()->GetTaskScheduler()->ScheduleTask(TaskType::k_mainThread, [=](const TaskContext&) noexcept
            {
                in_delegate(out_resource);
            });
        }
    }
コード例 #4
0
ファイル: ContentReader.cpp プロジェクト: jlyonsmith/ParseXnb
// Parses the entire contents of an XNB file.
void ContentReader::ReadXnb()
{
    // Read the XNB header.
    uint32_t endPosition = ReadHeader();

    ReadTypeManifest();

    uint32_t sharedResourceCount = Read7BitEncodedInt();

    // Read the primary asset data.
    Log.WriteLine("Asset:");

    ReadObject();

    // Read any shared resource instances.
    for (uint32_t i = 0 ; i < sharedResourceCount; i++)
    {
        Log.WriteLine("Shared resource %d:", i);
        
        ReadObject();
    }

    // Make sure we read the amount of data that the file header said we should.
    if (FilePosition() != endPosition)
    {
        throw app_exception("End position does not match XNB header: unexpected amount of data was read.");
    }
}
コード例 #5
0
ファイル: LZW.hpp プロジェクト: Nuos/CompressionAlgorithms
    void Decompress(char* source, char* dest) {
        assert(source != nullptr);
        assert(dest != nullptr);

        BinaryReader reader(source);
        BinaryWriter writer(dest);
        
        ReadHeader(reader);
        maxDictSize_ = 1 << indexBits_;
        AllocateDictionary();
        
        TrieNode* previousNode = nullptr;
        unsigned char firstChar;
        unsigned char lastChar;

        while(reader.IsEOF() == false) {
            int index = reader.ReadBits(IndexBits());
            if(index == maxDictSize_ -1) break;
            
            if(index >= dictSize_) {
                firstChar = WriteString(previousNode, writer);
                writer.WriteByte(lastChar);
            }
            else {
                firstChar = WriteString(nodes_[index], writer);
            }
            
            if(previousNode) {
                InsertValue(firstChar, previousNode);
            }

            lastChar = firstChar;
            previousNode = nodes_[index];
        }
    }
コード例 #6
0
ファイル: drawable.cpp プロジェクト: Wynjones1/game
Mesh::Mesh(Program &program, const char *filename)
	: Drawable(program)
	, vbuffer(-1)
	, nbuffer(-1)
	, tbuffer(-1)
	, fbuffer(-1)
	, texture(NULL)
{
	FILE *fp = fopen(filename, "r");
	if(!fp)
	{
		std::cout << "Could not open file: " << filename << " :" << strerror(errno) << std::endl;
		exit(-1);
	}

	int  num_vertices, num_faces;
	bool have_normals = false;
	bool have_tex = false;
	//Read the header
	ReadHeader(fp, num_vertices, num_faces, have_normals, have_tex);
	ReadVertexData(fp, num_vertices, have_normals, have_tex);
	ReadFaceData(fp, num_faces);

	InitBuffers();
}
コード例 #7
0
    void Decompress(char* source, char* dest) {
        BinaryReader reader(source);
        ReadHeader(reader);

        BinaryWriter writer(dest);
        SlidingWindow window(nullptr, bufferSize_, MaxOffset(), MaxLength() - 1);
        window.Initialize();

        while(reader.IsEOF() == false) {
            int length = reader.ReadBits(lengthBits_);
            int value;

            if(length == MaxLength()) {
                break;
            }
            if(length == 0) {
                value = reader.ReadByte();
            }
            else {
                int offset = reader.ReadBits(offsetBits_);
                value = reader.ReadByte();

                for(int i = 0; i < length; i++) {
                    int temp = window.CurrentByte(-offset - 1);
                    writer.WriteByte(temp);
                    window.WriteByte(temp);
                    window.AdvanceWindow(1);
                }
            }

            writer.WriteByte(value);
            window.WriteByte(value);
            window.AdvanceWindow(1);
        }
    }
コード例 #8
0
ファイル: movie.cpp プロジェクト: lioncash/citra
u64 Movie::GetMovieProgramID(const std::string& movie_file) const {
    auto header = ReadHeader(movie_file);
    if (header == boost::none)
        return 0;

    return static_cast<u64>(header.value().program_id);
}
コード例 #9
0
ファイル: 3DSParser.cpp プロジェクト: dulton/53_hero
/* Moves the cursor past the chunk header, which is six bytes. */
void t3DSParser::EnterChunk()
{
    if(m_xFile == 0 || !m_xFile->isOpen())
        return;

    ReadHeader();
}
コード例 #10
0
ファイル: client.cpp プロジェクト: AlbrechtL/anyrpc
bool Client::GetPostResult(Value& result)
{
    log_trace();
    gettimeofday( &startTime_, 0 );
    result.SetInvalid();

    if (responseProcessed_)
    {
        PreserveReceiveBuffer();
        ResetTransaction();
    }

    if (socket_.IsConnected(0) &&
        ReadHeader(result) &&
        ReadResponse(result))
    {
        switch (ProcessResponse(result))
        {
            case ProcessResponseSuccess       : return true;
            case ProcessResponseErrorKeepOpen : return false;
        }
    }

    Reset();
    return false;
}
コード例 #11
0
ファイル: cadfile.cpp プロジェクト: Mavrx-inc/gdal
int CADFile::ParseFile( enum OpenOptions eOptions, bool bReadUnsupportedGeometries )
{
    if( nullptr == pFileIO )
        return CADErrorCodes::FILE_OPEN_FAILED;

    if( !pFileIO->IsOpened() )
    {
        if( !pFileIO->Open( CADFileIO::read | CADFileIO::binary ) )
            return CADErrorCodes::FILE_OPEN_FAILED;
    }

    // Set flag which will tell CADLayer to skip/not skip unsupported geoms
    bReadingUnsupportedGeometries = bReadUnsupportedGeometries;

    int nResultCode;
    nResultCode = ReadSectionLocators();
    if( nResultCode != CADErrorCodes::SUCCESS )
        return nResultCode;
    nResultCode = ReadHeader( eOptions );
    if( nResultCode != CADErrorCodes::SUCCESS )
        return nResultCode;
    nResultCode = ReadClasses( eOptions );
    if( nResultCode != CADErrorCodes::SUCCESS )
        return nResultCode;
    nResultCode = CreateFileMap();
    if( nResultCode != CADErrorCodes::SUCCESS )
        return nResultCode;
    nResultCode = ReadTables( eOptions );
    if( nResultCode != CADErrorCodes::SUCCESS )
        return nResultCode;

    return CADErrorCodes::SUCCESS;
}
コード例 #12
0
ファイル: CConsolePort.cpp プロジェクト: fedor4ever/testexec
/*********************************************************************
 *
 *  ReceiveBytes() 
 *
 ********************************************************************/
int CConsolePort::ReceiveBytes( char* aBuff, int *aSize)
{
	int ret = 0;

	// If we are just the data part of the frame iReadingFlag is true
	if( iReadingData == 1 ) 
	{
		ret = ReadData( aBuff, aSize );
		if ( ret != 0 )
			return -1;
	
	}
	else
	{
		// Else we are reading the header - so get the next command
		ret = ReadHeader( aBuff, aSize );
		if ( ret != 0 )
			return -1;

		// Set the flag to true now that we have read the header,
		// so that the data part is read in the next iteration.
		iReadingData = 1;
	}
	
	// Return 
	return ret;
}
コード例 #13
0
bool RINEX_NavigationMessage::_Read(std::ifstream &ifs)
{
	std::string buf;

	if (ifs == 0)
	{
		return false;
	}
	else
	{
		// Do nothing
	}

	if (false == ReadHeader(ifs, leapSecond))
	{
		return false;
	}
	else
	{
		// Do nothing
	}

	if (false == ReadBody(ifs, leapSecond))
	{
		return false;
	}
	else
	{
		// Do nothing
	}

	return true;
}
コード例 #14
0
ファイル: iss_ogg.c プロジェクト: cbxbiker61/nogravity
static int Open(void *context, SYS_FILEHANDLE file, V3XA_HANDLE *info)
{
	OGG_context *ctx = (OGG_context*)context;
	ReadHeader(ctx, file);

	if (info)
	{
		int playLength, fileSize;
		info->samplingRate = ctx->vi.rate;
#ifdef SUPPORT_IEEE_AUDIO
		info->sampleFormat = V3XA_FMTIEEE;
#else
		info->sampleFormat = V3XA_FMT16BIT;
#endif
		if (ctx->vi.channels >= 2)
			info->sampleFormat|= V3XA_FMTSTEREO;
		fileSize = FIO_cur->fsize(file);
		playLength = (fileSize * 8) / ctx->vi.bitrate_nominal;
		info->length = playLength * ctx->vi.rate << 1;
		info->loopend = 0;
		info->loopstart = 0;
		info->codec = &V3XA_Codec_OGG;
	}
	return 1;
}
コード例 #15
0
ファイル: CLoader7Z.cpp プロジェクト: teddy-michel/TEngine
void CLoader7Z::ReadBloc(const std::streampos offset, const std::size_t size)
{
#ifdef T_DEBUG
    CApplication::getApp()->log(CString("Lecture de %1 octets depuis l'offset %2").arg(size).arg(offset), ILogger::Debug);
#endif

    if (size == 0)
        return;

    char * header = new char[size];

    m_file.seekg(offset, std::ios_base::beg);
    m_file.read(header, size);

    try
    {
        switch (header[0])
        {
        case kHeader:
            ReadHeader(header);
            break;

        case kEncodedHeader:
            ReadEncodedHeader(header);
            break;
        }
    }
    catch (...)
    {
        //...
    }

    delete[] header;
    return;
}
コード例 #16
0
ファイル: lvlarchive.cpp プロジェクト: crafn/alive
void LvlArchive::Load()
{
    // Read and validate the header
    LvlHeader header;
    ReadHeader(header);
    if (header.iNull1 != 0 || header.iNull2 != 0 || header.iMagic != MakeType('I', 'n', 'd', 'x'))
    {
        LOG_ERROR("Invalid LVL header");
        throw InvalidLvl("Invalid header");
    }

    // Read the file records
    std::vector<FileRecord> recs;
    recs.reserve(header.iNumFiles);
    for (auto i = 0u; i < header.iNumFiles; i++)
    {
        FileRecord rec;
        mStream.ReadBytes(&rec.iFileNameBytes[0], sizeof(rec.iFileNameBytes));
        mStream.ReadUInt32(rec.iStartSector);
        mStream.ReadUInt32(rec.iNumSectors);
        mStream.ReadUInt32(rec.iFileSize);
        recs.emplace_back(rec);
    }

    for (const auto& rec : recs)
    {
        mFiles.emplace_back(std::make_unique<File>(mStream, rec));
    }

    LOG_INFO("Loaded LVL '" << mStream.Name() << "' with " << header.iNumFiles << " files");
}
コード例 #17
0
ファイル: movie.cpp プロジェクト: lioncash/citra
void Movie::PrepareForPlayback(const std::string& movie_file) {
    auto header = ReadHeader(movie_file);
    if (header == boost::none)
        return;

    init_time = header.value().clock_init_time;
}
コード例 #18
0
ファイル: esignal.c プロジェクト: RobBullen/AudioMorphing
FieldList
OpenIn(char	*filename,	/* name of input file */
       char     **version,	/* version (output) */
       int      *arch,		/* architecture (output) */
       long     *pre_size,	/* preamble size (output) */
       long     *hdr_size,	/* header size (output) */
       long     *rec_size,	/* record size (output) */
       FILE     **file)		/* input file (output) */
{
    FILE    *input;

    if (filename == NULL)
	return NULL;

    if (strcmp(filename, "-") == 0)
	input = stdin;
    else
	input = fopen(filename, "r");

    if (input == NULL)
	return NULL;

    if (file != NULL)
	*file = input;

    return ReadHeader(version, arch, pre_size, hdr_size, rec_size, input);
}
コード例 #19
0
ファイル: movie.c プロジェクト: paul-met/yabause
int PlayMovie(const char *filename) {

	char* str=malloc(1024);

	if(Movie.Status == Recording)
		StopMovie();


	if ((Movie.fp = fopen(filename, "r+b")) == NULL)
	{
		free(str);
		return -1;
	}

	strcpy(str, filename);
	Movie.filename=str;
	PlaybackFileOpened=1;
	framecounter=0;
	Movie.ReadOnly = 1;
	Movie.Status=Playback;
	Movie.Size = MovieGetSize(Movie.fp);
	strcpy(MovieStatus, "Playback Started");
	ReadHeader(Movie.fp);
	YabauseReset();
	return 0;
}
コード例 #20
0
ファイル: BlockFileIO_2.c プロジェクト: Margulis/via
/*
** read several rows of data from a file
*/
void
VReadObjectData (FILE *fp,int object_id,VImage *image)
{
  static VImageInfo imageInfo;
  static VAttrList list=NULL;

  fseek(fp,0L,SEEK_SET);
  if (! ReadHeader (fp)) VError("error reading header"); 


  if (! (list = ReadAttrList (fp)))  
    VError("error reading attr list"); 
  
  if (! VGetImageInfo(fp,list,object_id,&imageInfo))
    VError(" error reading image info");

  if (imageInfo.nbands != VImageNBands((*image)))
    VError("incorrect number of bands");
  if (imageInfo.nrows != VImageNRows((*image))) 
    VError("incorrect number of rows");
  if (imageInfo.ncolumns != VImageNColumns((*image)))
    VError("incorrect number of columns");
  if (imageInfo.repn != VPixelRepn((*image))) 
    VError("incorrect pixel representation");
  
  if (! VReadBlockData (fp,&imageInfo,0,imageInfo.nrows,image))
    VError(" error reading data");
}
コード例 #21
0
ファイル: Xfer.C プロジェクト: EricAlex/ThirdParty-dev
bool
Xfer::ReadPendingMessages()
{
    // While there are complete messages, read them.
    while(ReadHeader())
    {
        if (opcode > nextSpecialOpcode && opcode < 0)
        {
            if (opcode == -1)
                bufferedInput.Flush();

            // If the callback and the data were provided, call the callback
            // so it can process the user-defined opcode.
            if(specialOpcodeCallback != 0)
                specialOpcodeCallback(opcode, specialOpcodeCallbackData);

            if (opcode == -1)
                return true;

            continue;
        }

        bufferedInput.WriteInt(opcode);
        bufferedInput.WriteInt(length);
        for (int i=0; i<length; i++)
        {
            unsigned char tmp;
            input->Read(&tmp);
            bufferedInput.Write(tmp);
        }
    }

    return false;
}
コード例 #22
0
///////////////////////////////////////////////////////////////////////////
//	Name:	ReadDataFile
//
//	Description:
//	Based on the type of data file, use the proper routine to read the data file
//	and put the data in the database.
//
//	Declaration:
//	bool CBinaryDataFile::ReadDataFile(CDbAccess* pDb, const CString &strNameWithPath, CString *pstrMsg)
//
//	Input:	pDb					Access database will write to
//			strNameWithPath		filename with full path that is to be opened
//			
//	Output:	pstrMsg				information about the import or error, if any
//
//	Return:	true (file imported okay) / false (some kind of error, see pstrMsg and miErrorNum)
//	
//  date    /	author	revision
//  -----------------	--------
//	22-Oct-2002	SFK		Created from ImportData in DbImport.cpp
//////////////////////////////////////////////////////////////////
bool CBinaryDataFile::ReadDataFile(
	CDbAccess* pDb, 
	const CString &strNameWithPath, 
	CString *pstrMsg)
{
	if (pstrMsg) pstrMsg->Empty();	// clear the return message string

	bool bStatus = false;

	//	Read read header information
    bStatus = ReadHeader(strNameWithPath, pstrMsg);
    if (!bStatus) {			// error reading header, can't continue
		if (mpFile) fclose(mpFile);
	    return(false);
	} 

	mstrFilenameWithPath = strNameWithPath;

	// header okay,now read the proper file
	CString strFileExtension;

	strFileExtension = strNameWithPath.Right(4);
	if (strFileExtension.CompareNoCase(".bin") == 0) 
		bStatus = ReadBinDataFile(pDb, strNameWithPath, pstrMsg);
	if (strFileExtension.CompareNoCase(".evt") == 0) 
		bStatus = ReadEvtDataFile(pDb, strNameWithPath, pstrMsg); 
	if (strFileExtension.CompareNoCase(".bny") == 0) 
		bStatus = ReadEvtDataFile(pDb, strNameWithPath, pstrMsg); 

	return(bStatus);
}
コード例 #23
0
// Decode a BER encoded PKCS12 structure
void PKCS12_Decoder::Decode()
{
    ReadHeader();
    if (source_.GetError().What()) return;

    // Get AuthSafe

    GetSequence();
    
        // get object id
    byte obj_id = source_.next();
    if (obj_id != OBJECT_IDENTIFIER) {
        source_.SetError(OBJECT_ID_E);
        return;
    }

    word32 length = GetLength(source_);

    word32 algo_sum = 0;
    while (length--)
        algo_sum += source_.next();

    
       



    // Get MacData optional
    /*
    mac     digestInfo  like certdecoder::getdigest?
    macsalt octet string
    iter    integer
    
    */
}
コード例 #24
0
WorldModelGroup::WorldModelGroup( std::string path, int groupIndex ) : GroupIndex(groupIndex), MOBA(NULL), IsBad(false)
{
    Data = new ChunkedData(path);
    if (!Data->Stream)
    {
        IsBad = true;
        return;
    }
    Chunk* mainChunk = Data->GetChunkByName("MOGP");
    int32 firstSub = mainChunk->FindSubChunkOffset("MOPY");
    if (firstSub == -1)
        return;

    Name = Utils::GetPlainName(path.c_str());

    FILE* stream = mainChunk->GetStream();
    fseek(stream, firstSub, SEEK_SET);
    SubData = new ChunkedData(stream, mainChunk->Length - firstSub);

    ReadHeader();
    ReadMaterials();
    ReadTriangles();
    ReadVertices();
    ReadNormals();
    ReadLiquid();
    ReadBatches();
}
コード例 #25
0
ファイル: TFileReader.hpp プロジェクト: CyberSys/X-Studio-2
         /// <summary>Reads all objects in the file</summary>
         /// <returns></returns>
         /// <exception cref="Logic::FileFormatException">File contains a syntax error</exception>
         /// <exception cref="Logic::IOException">An I/O error occurred</exception>
         TFilePtr  ReadFile(MainType t, GameVersion v)
         {
            // Skip comments
            while (ReadComment())
            {}

            // Parse header
            int  ver   = ReadInt(L"File version");
            int  count = ReadInt(L"Number of objects");

            // TODO: Validate version

            // Create file
            TFile<OBJ>* file = new TFile<OBJ>(count);
            TFilePtr output(file);

            // Parse objects
            for (int i = 0; i < count; ++i)
            {
               OBJ obj(t);

               // Read header/contents/footer
               ReadHeader(obj);
               ReadObject(obj, v);
               ReadFooter(obj);

               // Add to file
               file->Objects.push_back(obj);
            }

            // Return non-generic file
            return output;
         }
コード例 #26
0
ファイル: SkGifCodec.cpp プロジェクト: crabfang/skia
/*
 * Assumes IsGif was called and returned true
 * Creates a gif decoder
 * Reads enough of the stream to determine the image format
 */
SkCodec* SkGifCodec::NewFromStream(SkStream* stream) {
    SkCodec* codec = nullptr;
    if (ReadHeader(stream, &codec, nullptr)) {
        return codec;
    }
    return nullptr;
}
コード例 #27
0
ファイル: FIL_Vista_File.c プロジェクト: KoraST/ft_BIU-1
VAttrList VReadFile (FILE *f, VReadFileFilterProc *filter)
{
    VAttrList list;
    long offset;
    int i;

    /* Ensure that the correct FIL_Vista data file header is there: */
    if (! ReadHeader (f))
	return NULL;

    /* Read all attributes in the file: */
    if (! (list = ReadAttrList (f)))
	return NULL;

    /* Swallow the delimiter and read the binary data following it: */
    offset = 0;
    if (! ReadDelimiter (f) || ! ReadData (f, list, filter, &offset)) {
	VDestroyAttrList (list);
	return NULL;
    }

    /* Now we should be at the end of the file: */
    i = fgetc (f);
    if (i != EOF) {
	ungetc (i, f);
	VWarning ("VReadFile: File continues beyond expected EOF");
    }
    return list;
}
コード例 #28
0
BOOL CDataIndex::UpdateChecksum(LPCTSTR DataFileName)
{
	BOOL retcode = FALSE;

	// build index filename
	CFileSpec fs(DataFileName);
	fs.SetExt(".ldx");

	// build cell starts filename
	CFileSpec ifs(DataFileName);
	ifs.SetExt(".ldi");

	// update the checksum for the index file
	FILE* f = fopen(fs.GetFullSpec(), "rb+");
	if (f) {
		if (ReadHeader(f)) {
			// make sure we have a valid data index file
			if (strcmp(m_Header.Signature, "LDAindex") == 0) {
				m_Header.Checksum = ComputeChecksum(DataFileName);
				m_Header.Version = 1.1f;

				WriteHeader(f);
				fclose(f);

				retcode = TRUE;
			}
		}
	}

	// update the checksum for the starts file
	if (retcode) {
		f = fopen(ifs.GetFullSpec(), "rb+");
		if (f) {
			if (ReadHeader(f)) {
				if (strcmp(m_Header.Signature, "LDAstarts") == 0) {
					m_Header.Checksum = ComputeChecksum(DataFileName);
					m_Header.Version = 1.1f;

					WriteHeader(f);
					fclose(f);
				}
			}
		}
	}

	return(retcode);
}
コード例 #29
0
ファイル: wad.c プロジェクト: samboy/Oblige
//
// ReadWadFile
//
glbsp_ret_e ReadWadFile(const char *filename)
{
  int check;
  char *read_msg;

  // open input wad file & read header
  in_file = fopen(filename, "rb");

  if (! in_file)
  {
    if (errno == ENOENT)
      SetErrorMsg("Cannot open WAD file: %s", filename); 
    else
      SetErrorMsg("Cannot open WAD file: %s [%s]", filename, 
          strerror(errno));

    return GLBSP_E_ReadError;
  }
  
  if (! ReadHeader(filename))
  {
    fclose(in_file);
    return GLBSP_E_ReadError;
  }

  PrintMsg("Opened %cWAD file : %s\n", (wad.kind == IWAD) ? 'I' : 'P', 
      filename); 
  PrintVerbose("Reading %d dir entries at 0x%X\n", wad.num_entries, 
      wad.dir_start);

  // read directory
  ReadDirectory();

  DisplayOpen(DIS_FILEPROGRESS);
  DisplaySetTitle("glBSP Reading Wad");
  
  read_msg = UtilFormat("Reading: %s", filename);

  DisplaySetBarText(1, read_msg);
  DisplaySetBarLimit(1, CountLumpTypes(LUMP_READ_ME, LUMP_READ_ME));
  DisplaySetBar(1, 0);

  UtilFree(read_msg);

  cur_comms->file_pos = 0;

  // now read lumps
  check = ReadAllLumps();

  if (check != wad.num_entries)
    InternalError("Read directory count consistency failure (%d,%d)",
      check, wad.num_entries);
  
  wad.current_level = NULL;

  DisplayClose();

  return GLBSP_E_OK;
}
コード例 #30
0
ファイル: Wave.hpp プロジェクト: tapetums/include
inline bool tapetums::Wave::ReadAllChunks()
{
    auto p = file.pointer();

    // RIFFチャンクの読み込み
    if ( ! ReadHeader(p) )
    {
        return false;
    }

    // データサイズを取得
    const auto end = p + *(uint32_t*)(p + 4) + 8;

    // ポインタを進める
    p += sizeof(RiffChunk);

    char     chunkId[4];
    uint32_t chunkSize;

    // RIFFサブチャンクの読み込み
    while ( p < end )
    {
        ::memcpy(chunkId,    p,     sizeof(chunkId));
        ::memcpy(&chunkSize, p + 4, sizeof(chunkSize));

        // チャンクデータの読み込み
        if ( 0 == ::memcmp(chunkId, chunkId_ds64, sizeof(chunkId)) )
        {
            // 'ds64' chunk
            ReadDataSize64Chunk(p + 8, chunkSize);
        }
        else if ( 0 == ::memcmp(chunkId, chunkId_fmt, sizeof(chunkId)) )
        {
            // 'fmt ' chunk
            if ( ! ReadFormatChunk(p + 8) )
            {
                return false;
            }
        }
        else if ( 0 == memcmp(chunkId, chunkId_data, sizeof(chunkId)) )
        {
            // 'data' chunk
            if ( chunkSize < UINT32_MAX )
            {
                data_size = chunkSize;
            }
            data_offset = p + 8;
        }

        // ポインタを次のチャンクまで進める
        p = ForwardPointer(p, chunkId, chunkSize);
        if ( nullptr == p )
        {
            return false;
        }
    }

    return true;
}