コード例 #1
0
ファイル: DirManager.cpp プロジェクト: ruthmagnus/audacity
bool DirManager::MoveToNewProjectDirectory(BlockFile *f)
{
   wxFileName newFileName;
   wxFileName oldFileName=f->mFileName;
   AssignFile(newFileName,f->mFileName.GetFullName(),FALSE); 

   if ( !(newFileName == f->mFileName) ) {
      bool ok = wxRenameFile(f->mFileName.GetFullPath(),
                             newFileName.GetFullPath());

      if (ok)
         f->mFileName = newFileName;
      else {
         ok = wxCopyFile(f->mFileName.GetFullPath(),
                         newFileName.GetFullPath());
         if (ok) {
            wxRemoveFile(f->mFileName.GetFullPath());
            f->mFileName = newFileName;
         }
         else
            return false;
      }
   }

   return true;
}
コード例 #2
0
ファイル: wxpopp_ppm.cpp プロジェクト: witwall/reorgpdf
int wxPopplerConvPPM::Output(void)
{
	if (!isready) return -1;
	if (!isopen) {
		isopen = AssignFile();
		if (!isopen) return -1;
	}
	//output one page
	doc->displayPage(splashOut, curpage, resolution, resolution, 0,
		gFalse, gTrue, gFalse);
	wxString fname, extname;
	switch (color) {
	case full:
		extname = _T("ppm"); break;
	case mono:
		extname = _T("pbm"); break;
	case gray:
		extname = _T("pgm"); break;
	}
	
	fname.Printf(_T("%s-%06d.%s"),rootName.c_str(),curpage,extname.c_str());
	lastpath = wxFileName(outputDir,fname).GetFullPath();
	wxCharBuffer cfile = wxConvUTF8.cWC2MB(lastpath.wc_str(*wxConvCurrent));
	splashOut->getBitmap()->writePNMFile(cfile.data());
	return ++curpage;
}
コード例 #3
0
ファイル: wxpopp_ppm.cpp プロジェクト: witwall/reorgpdf
bool wxPopplerConvPPM::Prepare(void)
{
	if (isready) return true;
	if (!isopen) {
		isopen = AssignFile();
		if (!isopen) return false;
	}
	//get page range
	InitPageRange();
	//setup splash
	switch (color) {
	case full:
		splashOut = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
		break;
	case mono:
		splashOut = new SplashOutputDev(splashModeMono1, 1, gFalse, paperColor);
		break;
	case gray:
		splashOut = new SplashOutputDev(splashModeMono8, 1, gFalse, paperColor);
		break;
	}
	splashOut->startDoc(doc->getXRef());
	curpage = firstpage;
	isready = true;
	return true;
}
コード例 #4
0
ファイル: wxpopp_ppm.cpp プロジェクト: witwall/reorgpdf
int wxPopplerConvPPM::OutputAll(void)
{
	if (!isready) return -1;
	if (!isopen) {
		isopen = AssignFile();
		if (!isopen) return false;
	}
	//output one page
	wxString fname, extname;
	switch (color) {
	case full:
		extname = _T("ppm"); break;
	case mono:
		extname = _T("pbm"); break;
	case gray:
		extname = _T("pgm"); break;
	}
	for (curpage = firstpage; curpage <= lastpage; curpage++) {
		doc->displayPage(splashOut, curpage, resolution, resolution, 0,
			gFalse, gTrue, gFalse);
		fname.Printf(_T("%s-%06d.%s"),rootName.c_str(),curpage,extname.c_str());
		wxCharBuffer cfile = wxConvUTF8.cWC2MB(fname.wc_str(*wxConvCurrent));
		splashOut->getBitmap()->writePNMFile(cfile.data());
	}
	return curpage;
}
コード例 #5
0
ファイル: wxpopp_ppm.cpp プロジェクト: witwall/reorgpdf
wxPopplerConvPPM::wxPopplerConvPPM(const wxString &name, const wxString &usr, const wxString &own)
{
	Initialize();
	if (!globalParams) {
		globalParams = new GlobalParams();
	}
	SetTargetFile(name);
	SetUserPassword(usr);
	SetOwnerPassword(own);
	
	isopen = AssignFile();
}
コード例 #6
0
ファイル: DirManager.cpp プロジェクト: ruthmagnus/audacity
bool DirManager::CopyToNewProjectDirectory(BlockFile *f)
{
   wxFileName newFileName;
   AssignFile(newFileName,f->mFileName.GetFullName(),FALSE); 

   if ( !(newFileName == f->mFileName) ) {
      bool ok = wxCopyFile(f->mFileName.GetFullPath(),
                           newFileName.GetFullPath());
      if (ok) {
         f->mFileName = newFileName;
      }
      else
         return false;
   }

   return true;
}
コード例 #7
0
ファイル: DirManager.cpp プロジェクト: ruthmagnus/audacity
// only determines appropriate filename and subdir balance; does not
// perform maintainence
wxFileName DirManager::MakeBlockFileName()
{
   wxFileName ret;
   wxString baseFileName;

   unsigned int filenum,midnum,topnum,midkey;

   while(1){

      /* blockfiles are divided up into heirarchical directories.
         Each toplevel directory is represented by "e" + two unique
         hexadecimal digits, for a total possible number of 256
         toplevels.  Each toplevel contains up to 256 subdirs named
         "d" + two hex digits.  Each subdir contains 'a number' of
         files.  */

      filenum=0;
      midnum=0;
      topnum=0;

      // first action: if there is no available two-level directory in
      // the available pool, try to make one

      if(dirMidPool.empty()){
         
         // is there a toplevel directory with space for a new subdir?

         if(!dirTopPool.empty()){

            // there's still a toplevel with room for a subdir

            DirHash::iterator i = dirTopPool.begin();
            int newcount        = 0;
            topnum              = i->first;
            

            // search for unused midlevels; linear search adequate
            // add 32 new topnum/midnum dirs full of  prospective filenames to midpool
            for(midnum=0;midnum<256;midnum++){
               midkey=(topnum<<8)+midnum;
               if(BalanceMidAdd(topnum,midkey)){
                  newcount++;
                  if(newcount>=32)break;
               }
            }

            if(dirMidPool.empty()){
               // all the midlevels in this toplevel are in use yet the
               // toplevel claims some are free; this implies multiple
               // internal logic faults, but simply giving up and going
               // into an infinite loop isn't acceptible.  Just in case,
               // for some reason, we get here, dynamite this toplevel so
               // we don't just fail.
               
               // this is 'wrong', but the best we can do given that
               // something else is also wrong.  It will contain the
               // problem so we can keep going without worry.
               dirTopPool.erase(topnum);
               dirTopFull[topnum]=256;
            }
            continue;
         }
      }

      if(dirMidPool.empty()){
         // still empty, thus an absurdly large project; all dirs are
         // full to 256/256/256; keep working, but fall back to 'big
         // filenames' and randomized placement

         filenum = rand();
         midnum  = (int)(256.*rand()/(RAND_MAX+1.));
         topnum  = (int)(256.*rand()/(RAND_MAX+1.));
         midkey=(topnum<<8)+midnum;

            
      }else{
         
         DirHash::iterator i = dirMidPool.begin();
         midkey              = i->first;

         // split the retrieved 16 bit directory key into two 8 bit numbers
         topnum = midkey >> 8;
         midnum = midkey & 0xff;
         filenum = (int)(4096.*rand()/(RAND_MAX+1.));

      }

      baseFileName.Printf(wxT("e%02x%02x%03x"),topnum,midnum,filenum);

      if(blockFileHash.find(baseFileName) == blockFileHash.end()){
         // not in the hash, good. 
         if(AssignFile(ret,baseFileName,TRUE)==FALSE){
            
            // this indicates an on-disk collision, likely due to an
            // orphaned blockfile.  We should try again, but first
            // alert the balancing info there's a phantom file here;
            // if the directory is nearly full of orphans we neither
            // want performance to suffer nor potentially get into an
            // infinite loop if all possible filenames are taken by
            // orphans (unlikely but possible)
            BalanceFileAdd(midkey);
 
         }else break;
      }
   }
   // FIX-ME: Might we get here without midkey having been set?
   BalanceFileAdd(midkey);
   return ret;
}