コード例 #1
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::OnOK() 
{
	HTREEITEM hChild;
	CArray<CMaterialProp,CMaterialProp&> &blockproplist=pDoc->blockproplist;
	int k;

	// copy Model Materials into the model
	blockproplist.RemoveAll();
	hChild=m_mylist.GetChildItem(ModelParent) ;
	while (hChild!=NULL)
	{
		k=(int) m_mylist.GetItemData(hChild);
		blockproplist.Add(LibProps[k]);
		hChild = m_mylist.GetNextSiblingItem(hChild) ;
	}

	// write Library Materials to disk

	CString LibName=BinDir+"heatlib.dat";
	FILE *fp;

	if ((fp=fopen(LibName,"wt"))==NULL) return;
	
	hChild=m_mytree.GetChildItem(LibParent);
	while(hChild!=NULL)
	{
		CopyItemToDisk(hChild,fp);
		hChild = m_mytree.GetNextSiblingItem(hChild) ;
	}

	fclose(fp);


	CResizableDialog::OnOK();
}
コード例 #2
0
ファイル: nsZipArchive.cpp プロジェクト: ahadzi/celtx
//---------------------------------------------
// nsZipArchive::ExtractFile
// This extracts the item to the filehandle provided.
// If 'aFd' is null, it only tests the extraction.
// On extraction error(s) it removes the file.
// When needed, it also resolves the symlink.
//---------------------------------------------
nsresult nsZipArchive::ExtractFile(nsZipItem *item, const char *outname,
                                   PRFileDesc* aFd)
{
  if (!item)
    return ZIP_ERR_PARAM;
  if (!mFd)
    return ZIP_ERR_GENERAL;

  // Directory extraction is handled in nsJAR::Extract,
  // so the item to be extracted should never be a directory
  PR_ASSERT(!item->isDirectory);

  //-- move to the start of file's data
  if (SeekToItem(item, mFd) != ZIP_OK)
    return ZIP_ERR_CORRUPT;

  nsresult rv;

  //-- extract the file using the appropriate method
  switch(item->compression)
  {
    case STORED:
      rv = CopyItemToDisk(item->size, item->crc32, aFd);
      break;

    case DEFLATED:
      rv = InflateItem(item, aFd);
      break;

    default:
      //-- unsupported compression type
      rv = ZIP_ERR_UNSUPPORTED;
  }

  //-- delete the file on errors, or resolve symlink if needed
  if (aFd) {
    PR_Close(aFd);
    if (rv != ZIP_OK)
      PR_Delete(outname);
#if defined(XP_UNIX) || defined(XP_BEOS)
    else if (item->isSymlink)
      rv = ResolveSymlink(outname);
#endif
  }

  return rv;
}
コード例 #3
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::CopyItemToDisk(HTREEITEM hItem, FILE *fp)
{
	HTREEITEM hChild;
	int i =(int) m_mytree.GetItemData(hItem);
	int j;
		
	if (IsFolder(hItem))
	{
		fprintf(fp,"<BeginFolder>\n");
		fprintf(fp,"<FolderName> = \"%s\"\n",FoldProps[i].FolderName);
		if(FoldProps[i].FolderURL!="")
			fprintf(fp,"<FolderURL> = \"%s\"\n",FoldProps[i].FolderURL);
		if(FoldProps[i].FolderVendor!="")
			fprintf(fp,"<FolderVendor> = \"%s\"\n",FoldProps[i].FolderVendor);

		hChild=m_mytree.GetChildItem(hItem) ;
		while (hChild!=NULL)
		{
			CopyItemToDisk(hChild,fp) ;
			hChild = m_mytree.GetNextSiblingItem(hChild) ;
		}

		fprintf(fp,"<EndFolder>\n");
	}
	else{
		fprintf(fp,"<BeginBlock>\n");
		fprintf(fp,"<BlockName> = \"%s\"\n",LibProps[i].BlockName);
		fprintf(fp,"<Kx> = %.17g\n",LibProps[i].Kx);
		fprintf(fp,"<Ky> = %.17g\n",LibProps[i].Ky);
		fprintf(fp,"<Kt> = %.17g\n",LibProps[i].Kt);
		fprintf(fp,"<qv> = %.17g\n",LibProps[i].qv);
		if (LibProps[i].npts>0)
		{ 
			fprintf(fp,"    <TKPoints> = %i\n",LibProps[i].npts);
		    for (j=0;j<LibProps[i].npts;j++)
			{
				fprintf(fp,"      %.17g	%.17g\n",LibProps[i].Kn[j].re, LibProps[i].Kn[j].im);
			}
		}
		fprintf(fp,"<EndBlock>\n\n");
	}
}