예제 #1
0
  //
  // GetDataCrc
  //
  // Get the crc of the mission data
  //
  U32 Mission::GetDataCrc() const
  {
    // Setup the crc stream for this mission
    SetupStream(STREAM_CRC);

    // Save the currently active stream
    const char * oldStream = FileSys::GetActiveStream();

    // Activate our stream
    FileSys::SetActiveStream(STREAM_CRC);

    // Use a running crc
    U32 crc = 0;

    // Add all key files
    AddFileCrc(Game::FILENAME_MISSION_CONFIG, crc);
    AddFileCrc(Game::FILENAME_MISSION_OBJECTS, crc);
    AddFileCrc(Game::FILENAME_MISSION_TERRAIN, crc);

    // Restore the old active stream
    FileSys::SetActiveStream(oldStream);

    // Delete the preview stream
    FileSys::DeleteStream(STREAM_CRC);

    // Return the resulting crc
    return (crc);
  }
예제 #2
0
파일: ioc.c 프로젝트: jamjr/Helios-NG
PUBLIC Stream *
Open(
     Object *	object,
     string	name,
     word	mode )
{
	word rc = Err_Null;
	Stream *stream = NULL;
	MCB *mcb;
	IOCReply1 *rep;
	word stlen;
	Port reply;

#ifdef SYSDEB
	SysDebug(ioc)("Open(%O,%N,%x)",object,name,mode);
#endif

	if( CheckObject(object,C_Locate) != Err_Null ) return Null(Stream);

	reply = NewPort();

	mcb = NewMsgBuf(0);
	rep = (IOCReply1 *)mcb->Control;

	InitMCB(mcb,MsgHdr_Flags_preserve,
		MyTask->IOCPort,reply,FC_GSP|FG_Open|object->FnMod);

	MarshalCommon(mcb,object,name);

	MarshalWord(mcb,mode);

	if( (rc = IOCMsg(mcb,NULL)) < Err_Null ) goto Done;

	stlen = sizeof(Stream) + (word)strlen(mcb->Data+rep->Pathname) + SafetyMargin;

	stream = (Stream *)Malloc(stlen);

	if( stream == NULL ) 
	{
		rc = EC_Error|SS_SysLib|EG_NoMemory|EO_Stream;
		goto Done;
	}
	else memclr( (void *)stream, (int)stlen );

	if( SetupStream( stream, mcb ) )
	{
		stream->Flags |= mode&Flags_SaveMode;
		InitSemaphore( &stream->Mutex, 1 );
		stream->Pos = 0;
	}

	AddStream( stream );	

	rc = Err_Null;
	
	if( mode & Flags_Append ) Seek(stream, S_End, 0);
    Done:
#ifdef SYSDEB
	SysDebug(ioc)("Open: %E stream: %S",rc,stream);
#endif
	FreeMsgBuf(mcb);

	if( rc < Err_Null ) FreePort(reply);

	object->Result2 = rc;
	return stream;
}