コード例 #1
0
ファイル: WimIn.cpp プロジェクト: Bernieboy/nds4ios
HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDatabase &db)
{
  RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));

  RINOK(ReadStreams(inStream, h, db));
  bool needBootMetadata = !h.MetadataResource.IsEmpty();
  if (h.PartNumber == 1)
  {
    int imageIndex = 1;
    for (int j = 0; j < db.Streams.Size(); j++)
    {
      // if (imageIndex > 1) break;
      const CStreamInfo &si = db.Streams[j];
      if (!si.Resource.IsMetadata() || si.PartNumber != h.PartNumber)
        continue;
      Byte hash[kHashSize];
      CByteBuffer metadata;
      RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash));
      if (memcmp(hash, si.Hash, kHashSize) != 0)
        return S_FALSE;
      wchar_t sz[32];
      ConvertUInt64ToString(imageIndex++, sz);
      UString s = sz;
      s += WCHAR_PATH_SEPARATOR;
      RINOK(ParseDir(metadata, metadata.GetCapacity(), s, db.Items));
      if (needBootMetadata)
        if (h.MetadataResource.Offset == si.Resource.Offset)
          needBootMetadata = false;
    }
  }
  
  if (needBootMetadata)
  {
    CByteBuffer metadata;
    RINOK(UnpackData(inStream, h.MetadataResource, h.IsLzxMode(), metadata, NULL));
    RINOK(ParseDir(metadata, metadata.GetCapacity(), L"0" WSTRING_PATH_SEPARATOR, db.Items));
  }
  return S_OK;
}
コード例 #2
0
void  COLLADA_Viewer::ParseDir(char *path)
{
    DIR *  dir;
    struct dirent * dent;

	dir = opendir(path);
	if (dir == 0) {
	    printf("can't open %s\n", path);
		return;
	}

	char pathname[MAX_PATH];
	char t_pathname[MAX_PATH];
    while (1) {
        dent = readdir(dir);
		if (dent == 0)
			break;

		if (dent->d_type == DT_DIR)
		{
			if (strcmp(dent->d_name, ".")==0 || strcmp(dent->d_name, "..")==0)
				continue;
			sprintf(pathname, "%s/%s", path, dent->d_name);
			ParseDir(pathname);
		} else if (dent->d_type == DT_REG)
		{
			size_t filelen = strlen(dent->d_name);
			if ( ((dent->d_name[filelen-4] == '.')) &&
				 ((dent->d_name[filelen-3] == 'd') || (dent->d_name[filelen-3] == 'D')) &&
				 ((dent->d_name[filelen-2] == 'a') || (dent->d_name[filelen-2] == 'A')) &&
				 ((dent->d_name[filelen-1] == 'e') || (dent->d_name[filelen-1] == 'E'))
				 )
			{
				sprintf(pathname, "%s/%s", path, dent->d_name);
				printf("%s is a collada document\n", pathname);
				sprintf(t_pathname, "%s/%s.raw", path, dent->d_name);
				Browser.AddThumbnail(pathname, t_pathname);
			}
		}
    } 

    closedir(dir);
}
コード例 #3
0
int main(int argc, char **argv)
{
	FILE *outfile = NULL;
	unsigned char *vars = NULL, *vars1 = NULL, *vars2 = NULL, *vars3 = NULL;
	int varsLen = 0, vars1Len = 0, vars2Len = 0, vars3Len = 0;
	int varsCount = 0, vars1Count = 0, vars2Count = 0, vars3Count = 0;
	int i = 0, x = 0, compression = 0;
	
	setlocale(LC_ALL,"Japanese");
	
	if(argc<3)
	{
		printf("usage: %s infolder outpck [-c/-e]\n\nFlags:\n-c = Compression mode. A little slow but all files will be compressed.\n-e = Extra encryption (required for scripts)",argv[0]);
		return 0;
	}
	
	pckhead.extraencrypt = 0;
	for(i = 3; i < argc; i++)
	{
		if(strcmp(argv[i],"-c") == 0)
			compression = 1;
		else if(strcmp(argv[i],"-e") == 0)
			pckhead.extraencrypt = 1;
	}
	
	ParseDir(argv[1]);
	vars = GetBuffer("vars.dat", argv[1], &varsLen, &varsCount);
	vars1 = GetBuffer("vars1.dat", argv[1], &vars1Len, &vars1Count);
	vars2 = GetBuffer("vars2.dat", argv[1], &vars2Len, &vars2Count);
	vars3 = GetBuffer("vars3.dat", argv[1], &vars3Len, &vars3Count);
	
	pckhead.headersize = 0x5c;
	pckhead.table1.size = pckhead.globalvartable.size = pckhead.globalvartablestr.size = varsCount;
	(int)pckhead.table1.buffer = 0x5c;
	(int)pckhead.globalvartable.buffer = (int)pckhead.table1.buffer+varsCount*8;
	(int)pckhead.globalvartablestr.buffer = (int)pckhead.globalvartable.buffer+varsCount*8;
	(int)pckhead.filenametable1.buffer = varsLen+pckhead.headersize;
	(int)pckhead.filenametable1.size = vars1Count;
	(int)pckhead.filenametable2.buffer = pckhead.filenametable1.buffer+vars1Len;
	(int)pckhead.filenametable2.size = vars2Count;
	(int)pckhead.filenametable3.buffer = pckhead.filenametable2.buffer+vars2Len;
	(int)pckhead.filenametable3.size = vars3Count;
	(int)pckhead.filenametable4.buffer = pckhead.filenametable3.buffer+vars3Len;
	pckhead.filenametable4.size = pckhead.filenamestr.size = pckhead.filetable.size = pckhead.filestart.size = filecount;
	(int)pckhead.filenamestr.buffer = (int)pckhead.filenametable4.buffer+pckhead.filenametable4.size*8;
	(int)pckhead.filetable.buffer = (int)pckhead.filenamestr.buffer+(wcslen(filenamebuff)*2);
	(int)pckhead.filestart.buffer = (int)pckhead.filetable.buffer+pckhead.filetable.size*8;
	pckhead.unk2 = 0x366;
	
	outfile = fopen(argv[2],"wb+");
	
	// quick hackish way to do this without having to duplicate code or do a bunch of stuff
	// on the first pass, write all of the file information so the space will be there and
	// then write the file data (compressed or otherwise) and count the totals
	// on the second pass only rewrite the file information which will this time be correct
	
	for(x = 0; x < 2; x++)
	{
		fwrite(&pckhead,1,sizeof(pckhead),outfile);
		fwrite(vars,1,varsLen,outfile);
		fwrite(vars1,1,vars1Len,outfile);
		fwrite(vars2,1,vars2Len,outfile);
		fwrite(vars3,1,vars3Len,outfile);
		//fwrite(&fileinfo,sizeof(FileEntry),filecount,outfile);
	
		for(i=0; i<filecount; i++)
		{
			fwrite(&fileinfo[i].nameoffset,1,4,outfile);
			fwrite(&fileinfo[i].namesize,1,4,outfile);
		}
		
		fwrite(filenamebuff,2,wcslen(filenamebuff),outfile);
		
		for(i=0; i<filecount; i++)
		{
			fwrite(&fileinfo[i].offset,1,4,outfile);
			fwrite(&fileinfo[i].size,1,4,outfile);
		}
	
		if(x == 0)
		{
			ParseFiles(outfile,argv[1],compression);
			
			fclose(outfile);
			outfile = fopen(argv[2],"rb+");
		}
	}
	
	fclose(outfile);
	
	return 0;
}
コード例 #4
0
bool COLLADA_Viewer::onInit(int argc, char **ppArgv)
{
	FWGLApplication::onInit(argc, ppArgv);

    glClearColor(0.3f,0.3f,0.7f, 0.0f);
	glClearDepthf(1.0f);
	glEnable(GL_DEPTH_TEST);

	FWDebugFont::setColor(1.f, 1.f, 1.f, 1.f);  

	InitFS();
	Browser.Init();

	psglLoadShaderLibrary("/app_home/shaders.bin");

	// Initialize the renderer
	_CrtRender.Init();
	_CrtRender.SetUsingVBOs(CrtTrue);
	_CrtRender.SetShowHiearchy(CrtTrue);
	glEnable(GL_TEXTURE_2D);							
	glShadeModel(GL_SMOOTH);							
	glClearColor(0.0f, 0.0f, 1.0f, 0.5f);				
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK ); 

    cgRTCgcInit();
	ParseDir("/app_home/");

  // Load the target file
	Browser.onUpdate();
	if (argc > 0)
	{
		char path_name[1024];
		mCurrentFile = ppArgv[0];
		sprintf(path_name, "%s%s", "/app_home/", ppArgv[0]);
		printf(path_name);
		load_ok  = _CrtRender.Load(path_name, NULL);
		if ( !load_ok )
   			return false;  
	}
	else if (Browser.GetSize() > 0)
	{
		mCurrentFile = Browser.GetThumbnail(0)->GetDocument();
		load_ok  = _CrtRender.Load(mCurrentFile, NULL);
		if ( !load_ok )
   			return false;  
	}
	// Get the gamepad so we can read it later 
	mpPad = FWInput::getDevice(FWInput::DeviceType_Pad,0);
	if(mpPad==NULL)
	{
	  printf("Error, couldn't get a pad\n");
	  exit(0);
	}

	mpInputX0 = mpPad->bindFilter();
	mpInputX0->setChannel(FWInput::Channel_XAxis_0);
	mpInputX0->setGain( 1.0f );
	mpInputX0->setDeadzone( 0.3f );

	mpInputY0 = mpPad->bindFilter();
	mpInputY0->setChannel(FWInput::Channel_YAxis_0);
	mpInputY0->setGain( 1.0f );
	mpInputY0->setDeadzone( 0.3f );

	mpInputX1 = mpPad->bindFilter();
	mpInputX1->setChannel(FWInput::Channel_XAxis_1);
	mpInputX1->setGain( 1.0f );
	mpInputX1->setDeadzone( 0.3f );

	mpInputY1 = mpPad->bindFilter();
	mpInputY1->setChannel(FWInput::Channel_YAxis_1);
	mpInputY1->setGain( 1.0f );
	mpInputY1->setDeadzone( 0.3f );


  	// initialize debug font library, then open console.
	int ret;
	CellDbgFontConfig cfg;
	memset(&cfg, 0, sizeof(CellDbgFontConfig));
	cfg.bufSize      = 512;
	cfg.screenWidth  = mDispInfo.mWidth;
	cfg.screenHeight = mDispInfo.mHeight;
	ret = cellDbgFontInit(&cfg);
	if (ret != CELL_OK) {
		printf("cellDbgFontInit() failed %x\n", ret);
		return true;
	}

	CellDbgFontConsoleConfig ccfg;
	memset(&ccfg, 0, sizeof(CellDbgFontConsoleConfig));
	ccfg.posLeft     = 0.1f;
	ccfg.posTop      = 0.6f;
	ccfg.cnsWidth    = 16;
	ccfg.cnsHeight   = 4;
	ccfg.scale       = 1.5f;
	ccfg.color       = 0xffffffff;
	mDbgFontID       = cellDbgFontConsoleOpen(&ccfg);
	if (mDbgFontID < 0) {
		printf("cellDbgFontConsoleOpen() failed %x\n", mDbgFontID);
		return true;
	}

	return true;
}
コード例 #5
0
ファイル: MoveAction.cpp プロジェクト: lazycoding/ClearTmp
	void MoveAction::Path(const std::wstring & path)
	{
		dest_path_ = path;

		dest_dir_ = ParseDir(path);
	}
コード例 #6
0
ファイル: MoveAction.cpp プロジェクト: lazycoding/ClearTmp
	MoveAction::MoveAction(const std::wstring & destDirectory)
		:dest_path_(destDirectory), orignal_reserved_(true)
	{
		dest_dir_ = ParseDir(destDirectory);
	}