Ejemplo n.º 1
0
BOOL CSoliDireDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
	CFileException fe;
	CFile* pFile = NULL;
	
	DWORD nFlags = CFile::modeReadWrite | CFile::shareExclusive;
	if (!is_packed())
		nFlags |= CFile::modeCreate;

	pFile = GetFile(lpszPathName, nFlags, &fe);

	if (pFile == NULL)
	{
		ReportSaveLoadException(lpszPathName, &fe,
			TRUE, AFX_IDP_INVALID_FILENAME);
		return FALSE;
	}

	CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
	saveArchive.m_pDocument = this;
	saveArchive.m_bForceFlat = FALSE;

	CWaitCursor wait;
	Serialize(saveArchive);     // save me
	saveArchive.Close();
	ReleaseFile(pFile, FALSE);

	SetModifiedFlag(FALSE);     // back to unmodified

	return TRUE;        // success
}
Ejemplo n.º 2
0
void CSoliDireDoc::Serialize(CArchive& ar)
{
	ar.Flush();
	CFile* fp = ar.GetFile( );
	if (ar.IsStoring())
	{
		if (is_packed() && IsModified())
			pack_added_file(fp);
		else	
			pack_all_file(fp);// pack the file
	}
	else
	{
		read_file(fp);
	}
}
Ejemplo n.º 3
0
void CSoliDire::extract_all_files()
{
	if (!is_packed() || !m_DirTree->m_pRoot)
		return;


	CFile ifile;

	if (ifile.Open(GetPathName(), CFile::modeRead | CFile::shareDenyWrite))
	{
		BROWSEINFO bi;
		ZeroMemory(&bi,sizeof(BROWSEINFO));
		LPMALLOC pMalloc;
		LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
		TCHAR * pth = new TCHAR[MAX_PATH];
		ZeroMemory(pth, MAX_PATH);
		if(pidl != NULL)
		{
			SHGetPathFromIDList(pidl,pth);
			if(SUCCEEDED(SHGetMalloc(&pMalloc)))//pidl指向的对象用完应该释放,之前忽略了
			{
				pMalloc->Free(pidl);
				pMalloc->Release();
			}
			CString path(pth);
			if (path != "")
			{
				n = 0;
				if (path.Right(1) != "\\")
					path += "\\";
				extract_all_files(m_DirTree->m_pRoot, &ifile, path);
				printf ("All(%d) files extracted successfuly.\n", m_DirTree->get_filenum());
			}
			else
				printf("Canceled.\n");
		}


	
	}
}
Ejemplo n.º 4
0
void CSoliDireDoc::extract_all_files()
{
	if (!is_packed() || !m_DirTree->m_pRoot)
		return;
	
	CFile ifile;

	if (ifile.Open(GetPathName(), CFile::modeRead | CFile::shareDenyWrite))
	{
		CString path;
		CFolderDialog dlg(&path);

		if (dlg.DoModal() == IDOK)
		{
			if (path.Right(1) != "\\")
				path += "\\";
			
			extract_all_files(m_DirTree->m_pRoot, &ifile, path);
		}
	}
}
Ejemplo n.º 5
0
BOOL CSoliDire::save_file()
{

	DWORD nFlags = CFile::modeReadWrite | CFile::shareExclusive;
	if (is_packed() && IsModified())
	{
		CFile ofile(path.GetBuffer(0), nFlags);
		pack_added_file(&ofile);
		printf("New-added files successfuly packed.\n");
		return TRUE;
	}
	else
	{

		CFileDialog dlg(FALSE, (LPCTSTR)"*.sdr|*.sdr||", NULL, OFN_OVERWRITEPROMPT, (LPCTSTR)"*.sdr|*.sdr||", NULL);   
		printf("Choose the location of the packed file\n");
		if(dlg.DoModal() == IDOK)   
		{   
			path = dlg.GetPathName();   
			nFlags |= CFile::modeCreate;
			CFile ofile(path.GetBuffer(0), nFlags);
			n = 0;

			pack_all_file(&ofile);// pack the file
			printf("All(%d) files successfuly packed.\n", m_DirTree->get_filenum());
			
			SetModifiedFlag(FALSE);     // back to unmodified
			return TRUE;
		}
		else
		{
			printf("Canceled.\n");
			return FALSE;
		}
	}
}
Ejemplo n.º 6
0
		if(names_p != NULL) {
			g_ptr_array_add(names, g_strdup(members[i].name));
		}
	}
	g_free(members);

	if(names_p != NULL) {
		char **namev = g_new(char *, names->len + 1);
		for(int i=0; i<names->len; i++) namev[i] = names->pdata[i];
		namev[names->len] = NULL;
		g_ptr_array_free(names, TRUE);
		(*names_p) = namev;
	}

	T ret = LLVMStructTypeInContext(ctx->ctx, &g_array_index(types, T, 0),
		types->len, is_packed(type) ? 1 : 0);
	g_array_free(types, TRUE);
	return ret;
}


/* arrays, while rigid according to is_rigid_type(), don't have a distinct LLVM
 * representation.
 */
LLVMTypeRef llvm_rigid_type(struct llvm_ctx *ctx, IDL_tree type)
{
	if(type == NULL) return LLVMVoidTypeInContext(ctx->ctx);
	switch(IDL_NODE_TYPE(type)) {
		case IDLN_TYPE_STRUCT:
			return llvm_struct_type(ctx, NULL, type);