Ejemplo n.º 1
0
void enter_subarchive(const char *name, struct_panel *panel) /* Вход во вложенный архив - принимает полный путь к архиву */
{
  char *subarchive=NULL;
  #ifdef __amd64
  char *prefix=strdup("/tmp/");
  #else
  char *prefix=detect_subarchive_prefix();
  #endif
  archive_extract_file(panel->archive_stack[panel->archive_depth], name, prefix);
  asprintf(&subarchive, "%s%s/%s", prefix, panel->archive_cwd, name);
  TRACE("Entering into subarchive '%s' of archive '%s'\n", subarchive, panel->archive_stack[panel->archive_depth]);
  enter_archive(subarchive, panel, TRUE);
  xfree(&prefix);
}
__LIBBOOTIMAGE_PRIVATE_API__  int check_bootimage_utils_file_type(struct bootimage_utils* biu)
{
	/* File Type Identification strategy

	   Factory Image Identification
	   Check for a known factory image file name.
	   Check if the file is a valid gzip magic.
	*/

	struct factory_images* fi =  &factory_image_info[0] ;
	char* bname = utils_basename(biu->file_name);
	D("bname=%s",bname);
	while ( fi->name != NULL ){
		/* D("fi=%p fi->name=%s fi->name_length=%d",fi,fi->name,fi->name_length); */
		if ( strncmp(fi->name,bname,fi->name_length) == FACTORY_IMAGE_STRNCMP_MATCH_FOUND ){
			D("Potential Factory Image File Found file_name=%s",biu->file_name);
			break ;
		}

		fi++;
	}

	if ( fi != NULL ) {
		/* For this to be a potentially bona-fida factory image the Gzip identifaction must be at the
		   start of the data */

		//char* magic = utils_memmem(biu->compressed_data,biu->stat.st_size,FACTORY_IMAGE_MAGIC_GZIP,FACTORY_IMAGE_MAGIC_GZIP_SIZE);
		//D("Factory Image Gzip Magic %p : biu-data[0] %p",magic ,biu->compressed_data ) ;
		//if ( magic == biu->compressed_data ){
		//	unsigned int uncompressed_size = archive_gzip_get_uncompressed_size(biu->compressed_data,biu->stat.st_size);
			size_t zip_size ,boot_image_size;
			char* zip_data = archive_extract_entry(biu->data,biu->stat.st_size, fi->zip_name,fi->zip_name_length,&zip_size);
			D("Factory Image zip data %p : zip_size %zu",zip_data,zip_size) ;

			 archive_extract_file(zip_data, zip_size,"boot.img",0);
			//D("Factory Image boot_image_data  %p : boot_image_size %zu",boot_image_data,boot_image_size) ;
			//D("Factory Image Gzip Magic %p : biu-data[0] %p",magic ,biu->compressed_data ) ;
		//}

	}
	return 0;
}
Ejemplo n.º 3
0
void CFileListView::ExtractFolder( FileInfo *pItem, const char* pCurrPath, const char *pSavePath )
{
	FileInfo *pSubItem;
	char szCurrPath[MAX_PATH];
	char szSavePath[MAX_PATH];
	char szPath[MAX_PATH];

	szCurrPath[0] = 0;
	if(pCurrPath && *pCurrPath)
	{
		strcat_s(szCurrPath, MAX_PATH, pCurrPath);
		strcat_s(szCurrPath, MAX_PATH, "\\");
	}
	strcat_s(szCurrPath, MAX_PATH, pItem->szName);

	sprintf_s(szSavePath, "%s\\%s", pSavePath, szCurrPath);
	if(!::CreateDirectory(szSavePath, NULL))
		return;

	for (size_t i=0; i<pItem->Chlids.size(); i++)
	{
		pSubItem = &(pItem->Chlids[i]);

		if(pSubItem->nFileSize > 0)
		{
			if(GetCurrentPath(szPath, MAX_PATH))
				strcat_s(szPath, MAX_PATH, "\\");

			strcat_s(szPath, MAX_PATH, szCurrPath);
			strcat_s(szPath, MAX_PATH, "\\");
			strcat_s(szPath, MAX_PATH, pSubItem->szName);

			sprintf_s(szSavePath, "%s\\%s\\%s", pSavePath, szCurrPath, pSubItem->szName);

			archive_extract_file(m_pArchive, szPath, szSavePath);
		}
		else
			ExtractFolder(pSubItem, szCurrPath, pSavePath);
	}
}
Ejemplo n.º 4
0
void CFileListView::ExtractFile(const char* pArcFile)
{
	char szSavePath[MAX_PATH];
	OPENFILENAME ofn = {0};

	const char* pName = strrchr(pArcFile, '\\');
	if(pName != NULL)
		strcpy_s(szSavePath, MAX_PATH, pName+1);
	else
		strcpy_s(szSavePath, MAX_PATH, pArcFile);

	ofn.lStructSize = sizeof(ofn); 
	ofn.hwndOwner = m_hWnd; 
	ofn.lpstrFilter = "所有文件(*.*)\0*.*\0";
	ofn.nFilterIndex = 0; 
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrFile = szSavePath;
	ofn.nMaxFile = MAX_PATH; 
	ofn.Flags = OFN_OVERWRITEPROMPT;

	if(GetSaveFileName(&ofn))
		archive_extract_file(m_pArchive, pArcFile, szSavePath);
}