コード例 #1
0
ファイル: SigCharged.cpp プロジェクト: jdfrankland/gemini
CSigCharged::CSigCharged(string sName0, float Zp0, float Ap0)
{

  Zp = Zp0;
  Ap = Ap0;
  if (sName0 == "neutron")
    {
      neutron = 1;
      return;
    }
  neutron = 0;
  sName = "tl/"+sName0+".inv";
   string fullName;
  if (getenv("GINPUT") == NULL) fullName = sName;
  else
    {
      string dir(getenv("GINPUT"));
     fullName = dir+sName;
    }
  ifstream ifFile (fullName.c_str());

  if (ifFile.fail() )
    {
      cout << "file " << fullName << " not found in CSigCharged" << endl;
      abort();
    }

  ifFile >> rc0 >> rc1 >> rc2;
  ifFile >> rI0 >> rI1 >> rI2;
  ifFile >> omega0 >> omega1 >> omega2 >> omega3;
  ifFile >> a0;
  ifFile >> aa0;
  ifFile.close();
  ifFile.clear();
}
コード例 #2
0
extern "C" void getInterfaces()
{
	system("ls /sys/class/net > /tmp/if");
	std::ifstream ifFile("/tmp/if");
	std::string line;
	while(std::getline(ifFile, line))
	{
		interfaces.push_back(line);
	}
	system("rm /tmp/if");
}
コード例 #3
0
ファイル: Gdr.cpp プロジェクト: jdfrankland/gemini
CGdr::CGdr()
{
  string fileName("tbl/GDR.inp");
  string fullName;
  if (getenv("GINPUT") == NULL) fullName = fileName;
  else
    {
      string dir(getenv("GINPUT"));
     fullName = dir+fileName;
    }
  ifstream ifFile (fullName.c_str());


  if (ifFile.fail())
    {
      cout << " file " << fullName << " not found" << endl;
      abort();
    }   

  //skip line
  string line;
  getline(ifFile,line);

  //read in paramters of Lorentzian's , up to five are allowed
  double a,b,c;
  N = 0;
  for (int i=0;i<5;i++)
    {
      ifFile >> a >> b >> c;
      if (ifFile.eof()) break;
      if (ifFile.bad()) break;
      if (a== 0.) break;
      lineShape[N].strength =  a;
      lineShape[N].energy = b;
      lineShape[N].gamma = c;
      N++;  
    }
  if (N == 0) 
    {
     cout << "no user-defined GDR" << endl;
     abort();
    }
}
コード例 #4
0
  /**
  * Reads the BoundImport directory from a PE file.
  * @param strModuleName The name of the PE file from which the BoundImport directory is read.
  * @param dwOffset The file offset where the BoundImport directory can be found (see #PeFile::PeHeader::getIDBoundImportRVA).
  * @param dwSize The size of the BoundImport directory (see #PeFile::PeHeader::getIDBoundImportSize).
  **/
  int BoundImportDirectory::read(const std::string& strModuleName, dword dwOffset, unsigned int uiSize)
  {
    std::ifstream ifFile(strModuleName.c_str(), std::ios::binary);

    if (!ifFile)
    {
      return ERROR_OPENING_FILE;
    }
    
    if (fileSize(ifFile) < dwOffset + uiSize)
    {
      return ERROR_INVALID_FILE;
    }
    
    ifFile.seekg(dwOffset, std::ios::beg);
    
    std::vector<unsigned char> vBimpDir(uiSize);
    ifFile.read(reinterpret_cast<char*>(&vBimpDir[0]), uiSize);

    InputBuffer inpBuffer(vBimpDir);
    
    return read(inpBuffer, &vBimpDir[0], uiSize);
   }
コード例 #5
0
ファイル: SigBarDist.cpp プロジェクト: jdfrankland/gemini
  /**
   * constructor
   /param sName0 is the name of the files containing fitted coeff.
  */
CSigBarDist::CSigBarDist(string sName0, float Zp0, float Ap0)
{

  Zp = Zp0;
  Ap = Ap0;
  string sName = sName0;
  sigCharged[1] = new CSigCharged(sName,Zp,Ap);


  sName = sName0+"P";
  //see if second file is there 

  string fullName;
  if (getenv("GINPUT") == NULL) fullName = "tl/"+sName+".inv";
  else
    {
      string dir(getenv("GINPUT"));
      fullName = dir+"tl/"+sName+".inv";
    }
  ifstream ifFile(fullName.c_str());

  if (ifFile.fail() || sName0 == "neutron" )
    {
      one = 1;
      return;
    }
  
  ifFile.close();
  ifFile.clear();
  one = 0;

  sigCharged[2] = new CSigCharged(sName,Zp,Ap); 
  sName = sName0+"M";
  sigCharged[0] = new CSigCharged(sName,Zp,Ap); 

}
コード例 #6
0
ファイル: DebugDirectory.cpp プロジェクト: CBaiz/PeLib
	/**
	* @param strFilename Name of the file which will be read.
	* @param uiOffset File offset of the Debug directory.
	* @param uiSize Size of the Debug directory.
	**/
	int DebugDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
	{
		std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
		unsigned int ulFileSize = fileSize(ifFile);

		if (!ifFile)
		{
			return ERROR_OPENING_FILE;
		}
		
		if (ulFileSize < uiOffset + uiSize)
		{
			return ERROR_INVALID_FILE;
		}

		ifFile.seekg(uiOffset, std::ios::beg);

		std::vector<byte> vDebugDirectory(uiSize);
		ifFile.read(reinterpret_cast<char*>(&vDebugDirectory[0]), uiSize);
		
		InputBuffer ibBuffer(vDebugDirectory);
		
		std::vector<PELIB_IMG_DEBUG_DIRECTORY> currDebugInfo = read(ibBuffer, uiSize);
		
		for (unsigned int i=0;i<currDebugInfo.size();i++)
		{
			ifFile.seekg(currDebugInfo[i].idd.PointerToRawData, std::ios::beg);
			currDebugInfo[i].data.resize(currDebugInfo[i].idd.SizeOfData);
			ifFile.read(reinterpret_cast<char*>(&currDebugInfo[i].data[0]), currDebugInfo[i].idd.SizeOfData);
			if (!ifFile) return ERROR_INVALID_FILE;
		}
		
		std::swap(currDebugInfo, m_vDebugInfo);
		
		return NO_ERROR;
	}
コード例 #7
0
ファイル: ComHeaderDirectory.cpp プロジェクト: 4nykey/rockbox
	/**
	* Reads a file's COM+ descriptor.
	* @param strFilename Name of the file.
	* @param uiOffset File offset of the COM+ descriptor.
	* @param uiSize Size of the COM+ descriptor.
	**/
	int ComHeaderDirectory::read(const std::string& strFilename, unsigned int uiOffset, unsigned int uiSize)
	{
		std::ifstream ifFile(strFilename.c_str(), std::ios::binary);
		unsigned int ulFileSize = fileSize(ifFile);

		if (!ifFile)
		{
			return ERROR_OPENING_FILE;
		}
		
		if (ulFileSize < uiOffset + uiSize)
		{
			return ERROR_INVALID_FILE;
		}

		ifFile.seekg(uiOffset, std::ios::beg);

		std::vector<byte> vComDescDirectory(uiSize);
		ifFile.read(reinterpret_cast<char*>(&vComDescDirectory[0]), uiSize);
		
		InputBuffer ibBuffer(vComDescDirectory);
		read(ibBuffer);
		return NO_ERROR;
	}
コード例 #8
0
ファイル: Evap.cpp プロジェクト: jdfrankland/gemini
/**
 * Constructor
 */
CEvap::CEvap() 
{

  string fileName("tbl/evap.inp");
  string fullName;
  if (getenv("GINPUT") == NULL) fullName = fileName;
  else
    {
      string dir(getenv("GINPUT"));
     fullName = dir+fileName;
    }
  ifstream ifFile (fullName.c_str());


  if (ifFile.fail())
    {
      cout << " file " << fullName << " not found" << endl;
      abort();
    }   

  // read in number of evaporation channels 
  ifFile >> nLight;
  prob = new float [nLight];
  // create array of CLightP pointers 
  lightP = new CLightP * [nLight];

  tlArray = new CTlBarDist * [nLight]; 
  sigBarDist = new CSigBarDist * [nLight]; 

  // read in channel information and initialize pointers
  decay = new SDecay [nLight];

  // skip line
  string line;
  getline(ifFile,line);
  getline(ifFile,line);



  
  float fJ, fEx, Ek, suppress;
  int iZ, iA;
  string nameOld("");
  string name("");
  bool newTl;
  nTl = 0;
  for (int i=0;i<nLight;i++)
    {
      nameOld = name;
      ifFile >> iZ >> iA >> fJ >> fEx >> name >> suppress >> Ek;


      // determine if we need to create new transmission coeff
      newTl = 1;
      if (i > 0)
	{
	  if (name == nameOld) newTl = 0;
	}
      if (newTl)
	{
          tlArray[nTl] = new CTlBarDist(name);
          sigBarDist[nTl] = new CSigBarDist(name,(float)iZ,(float)iA);
          nTl++; 
	}       
      lightP[i] = new CLightP(iZ,iA,fJ,tlArray[nTl-1],sigBarDist[nTl-1]);
      lightP[i]->rLight = pow((float)iA,(float)(1./3.))*r0;
      lightP[i]->fEx = fEx;
      lightP[i]->suppress = suppress;
      // if an excited state add excitation energy to mass excess
      if (fEx > 0.0) lightP[i]->fExpMass += fEx;
      maxZ = iZ;
      decay[i].Ek = Ek;
      if (Ek == 0.) continue;
      // read in decay information 
        ifFile >> decay[i].Z1 >> decay[i].A1 >> decay[i].S1 >> 
	  decay[i].S2 >> decay[i].L >> decay[i].lPlusS1 >> decay[i].gamma;

	// here are sum checks to make sure decay information is possible
        if (decay[i].lPlusS1 > decay[i].S1 + (float)decay[i].L)
	  {
	  cout << "bad LPlusS1 in evap.cpp for mode " << i << endl;
	  abort();
	  }

        if (decay[i].lPlusS1 < fabs(decay[i].S1 - (float)decay[i].L))
	  {
	  cout << "bad LPlusS1 in evap.cpp for mode " << i << endl;
	  abort();
	  }

        if (fJ > decay[i].lPlusS1+decay[i].S2)
	  {
	  cout << "bad fJ in evap.cpp for mode " << i << endl;
	  abort();
	  }

        if (fJ < fabs(decay[i].lPlusS1-decay[i].S2))
	  {
	  cout << "bad fJ in evap.cpp for mode " << i << endl;
	  abort();
	  }
  
    }

  ifFile.clear();
  ifFile.close();

  
}