コード例 #1
0
ファイル: scidoc.cpp プロジェクト: yetanothergeek/fxite
bool SciDoc::SaveToFile(const char*filename, bool as_itself)
{
#ifdef WIN32
  FXFile fh(filename, FXIO::WriteOnly|FXIO::Truncate|((FXStat::exists(filename))?0:FXIO::Create));
#else
  FXFile fh(filename, FXIO::Writing);
#endif
  _lasterror="";
  if (fh.isOpen()) {
    FXbool en=isEnabled();
    FXbool hf=hasFocus();
    FXTextCodec *codec=NULL;
    FXString recode=FXString::null;
    if (en) { disable(); }
    FXint len=sendMessage(SCI_GETLENGTH,0,0);
    const char*buf=(const char*)sendMessage(SCI_GETCHARACTERPOINTER,0,0);
    if (bom[0]) {
      fh.writeBlock(bom,strlen(bom));
      switch ((FXuchar)bom[0]) {
        case 0xFF: {
          codec=new FXUTF16LECodec();
          break;
        }
        case 0xFE: {
          codec=new FXUTF16BECodec();
          break;
        }
      }
    }
    if (codec) {
      FXint old_len=len;
      len=codec->utf2mblen(buf,old_len);
      recode.length(len);
      codec->utf2mb((char*)recode.text(),len,buf,old_len);
      delete codec;
      buf=recode.text();
    }
    FXival wrote=fh.writeBlock(buf,len);
    if (en) { enable(); }
    if (hf) { setFocus(); }
    if (fh.close() && (wrote==len)) {
      if (as_itself) {
        if (_filename.empty() && !getLanguage()) {
          if (!SetLanguageForHeader(filename)) {
            if (!setLanguageFromFileName(FXPath::name(filename).text())) {
              setLanguageFromContent();
            }
          }
        }
        _filename=FXPath::absolute(filename);
        _filetime=FXStat::modified(_filename);
        sendMessage(SCI_SETSAVEPOINT,0,0);
        DoStaleTest(true);
      }
      return true;
    }
  }
  _lasterror=SystemErrorStr();
  return false;
}
コード例 #2
0
ファイル: ZON.cpp プロジェクト: exjam/r3e
	bool ZON::Load(const char* path){
		ScopedPointer<File> fh(FILE_SYS()->OpenFile(path, "rb"));
		if(!fh) return false;

		unsigned int blocks, type, offset;
		fh->Read(blocks);
		for(unsigned int i = 0; i < blocks; ++i){
			fh->Read(type);
			fh->Read(offset);
			long pos = fh->Position();
			switch(type){
				case TEXTURE_LIST:
					fh->Seek(offset);
					ReadTextureList(fh);
					break;
				case TILE_LIST:
					fh->Seek(offset);
					ReadTileList(fh);
					break;
			}

			fh->Seek(pos);
		}

		fh->Close();
		return true;
	}
コード例 #3
0
void RemoteControl::sendActivePlaylist(int index)
{
	if (!_webSocket) {
		return;
	}

	QStringList args;
	args << QString::number(CMD_LoadActivePlaylist);

	if (_currentView && _currentView->viewProperty(Settings::VP_PlaylistFeature)) {
		AbstractViewPlaylists *playlistsView = qobject_cast<AbstractViewPlaylists*>(_currentView);
		MediaPlaylist *mp = playlistsView->playlists().at(index);

		// Send track count first, then all tracks in a big "blob"
		for (int i = 0; i < mp->mediaCount(); i++) {
			FileHelper fh(mp->media(i));
			//out << fh.title() << fh.trackNumber() << fh.album() << fh.artistAlbum() << fh.year() << QString::number(fh.rating());
			/*tracks.append(fh.title());
			tracks.append(fh.trackNumber());
			tracks.append(fh.album());
			tracks.append(fh.artistAlbum());
			tracks.append(fh.year());
			tracks.append(QString::number(fh.rating()));*/
		}
		//out << tracks.size();
		//out << tracks;
		_webSocket->sendTextMessage(args.join(QChar::Null));
	}
}
コード例 #4
0
  QApplicationTOPP::QApplicationTOPP(int& argc, char** argv) :
    QApplication(argc, argv)
  {
    // register GUI ProgressLogger that can be used in GUI tools
    Factory<ProgressLogger::ProgressLoggerImpl>::registerProduct(GUIProgressLoggerImpl::getProductName(), &GUIProgressLoggerImpl::create);

    // set plastique style unless windows / mac style is available
    if (QStyleFactory::keys().contains("windowsxp", Qt::CaseInsensitive))
    {
      this->setStyle("windowsxp");
    }
    else if (QStyleFactory::keys().contains("macintosh", Qt::CaseInsensitive))
    {
      this->setStyle("macintosh");
    }
    else if (QStyleFactory::keys().contains("plastique", Qt::CaseInsensitive))
    {
      this->setStyle("plastique");
    }

    // customize look and feel via Qt style sheets
    String filename = File::find("GUISTYLE/qtStyleSheet.qss");
    QFile fh(filename.toQString());
    fh.open(QFile::ReadOnly);
    QString style_string = QLatin1String(fh.readAll());
    //std::cerr << "Stylesheet content: " << style_string.toStdString() << "\n\n\n";
    this->setStyleSheet(style_string);
  }
コード例 #5
0
ファイル: md5_hasher.cpp プロジェクト: amireh/Karazeh
  hasher::digest_rc md5_hasher::hex_digest(path_t const& fp) const {
    std::ifstream fh(fp.c_str(), std::ifstream::in | std::ifstream::binary);
    digest_rc rc(hex_digest(fh));
    fh.close();

    return rc;
  }
コード例 #6
0
ファイル: DocReader.cpp プロジェクト: killbug2004/WSProf
CStdStringW DocReader::GetMainDocumentText()
{
	CStdStringW sDocText =  GetDocumentText(m_pFIB->ccpText);
	FieldHandler fh(sDocText);
	fh.ReplaceFieldsWithResults();
	return sDocText;
}
コード例 #7
0
ファイル: auth.cpp プロジェクト: artasoftkey/entropybroker
bool get_auth_from_file(char *filename, std::string & username, std::string & password)
{
	struct stat ss;

	if (stat(filename, &ss) == -1)
		error_exit("stat(%s) failed", filename);

	if (ss.st_mode & (S_IRWXG | S_IRWXO))
		error_exit("file %s must only readable by its owner", filename);

	std::ifstream fh(filename);
	if (!fh.is_open())
		error_exit("Cannot open %s", filename);

	std::string line;
	std::getline(fh, line);
	username.assign(line);

	std::getline(fh, line);
	password.assign(line);

	fh.close();

	return true;
}
コード例 #8
0
ファイル: StructCompactor.cpp プロジェクト: hleclerc/Metil
void StructCompactor::make_files( const String &dir ) {
    File fh( dir + '/' + item->type + ".h", "w" );
    fh << "#ifndef " << item->type << "_H\n";
    fh << "#define " << item->type << "_H\n";
    fh << "\n";
    fh << "#include <Metil/MemoryDriver.h>\n";
    fh << "#include <Metil/BasicVecRef.h>\n";
    fh << "\n";
    fh << "BEG_METIL_NAMESPACE\n";
    fh << "\n";
    item->make_decl( fh );
    fh << "\n";
    fh << "END_METIL_NAMESPACE\n";
    fh << "\n";
    fh << "#endif // " << item->type << "_H\n";

    File fc( dir + '/' + item->type + ".cu", "w" );
    fc << "#include \"" << item->type << ".h\"\n";
    fc << "\n";
    fc << "BEG_METIL_NAMESPACE\n";
    fc << "\n";
    BasicVec<String> already_defined;
    item->make_defi( fc, "", already_defined );
    fc << "\n";
    fc << "END_METIL_NAMESPACE\n";
}
コード例 #9
0
ファイル: CommonDefHandler.cpp プロジェクト: javaphoon/spring
int CommonDefHandler::LoadSoundFile(const std::string& fileName)
{
	const std::string extension = filesystem.GetExtension(fileName);
	bool hasFile = false;
	if (extension == "wav" || extension == "ogg")
	{
		CFileHandler raw(fileName);
		if (raw.FileExists())
			hasFile = true;
	}

	if (!sound->HasSoundItem(fileName) && !hasFile)
	{
		std::string soundFile = "sounds/" + fileName;

		if (extension.empty()) {
			// extension missing, try wav
			soundFile += ".wav";
		}
		CFileHandler fh(soundFile);
		if (fh.FileExists()) {
			// we have a valid soundfile: store name, ID, and default volume
			const int id = sound->GetSoundId(soundFile);
			return id;
		}
	}
	else
	{
		const int id = sound->GetSoundId(fileName);
		return id;
	}
	return 0;
}
コード例 #10
0
   void
   FileFilterFrameWithHeader<FileStream,FileData,FileHeader> :: 
   init(const std::vector<FileHunter::FilterPair>& filter)
      throw(gpstk::Exception)
   {
         // find the files
      FileHunter fh(this->fs);
   
      typename std::vector<FileHunter::FilterPair>::const_iterator itr = 
         filter.begin();
      while (itr != filter.end())
      {
         fh.setFilter((*itr).first, (*itr).second);
         itr++;
      }

      std::vector<std::string> listOfFiles = 
         fh.find(this->startTime, this->endTime, FileSpec::ascending);

         // for each file, just read the header
      typename std::vector<std::string>::iterator i;
      for(i = listOfFiles.begin(); i != listOfFiles.end(); i++)
      {
         FileStream s((*i).c_str());

         if (s.good())
         {
            s.exceptions(std::ios::failbit);

            FileHeader header;
            s >> header;
            headerList.push_back(header);
         }
      }
コード例 #11
0
ファイル: LuaParser.cpp プロジェクト: Dmytry/spring
int LuaParser::LoadFile(lua_State* L)
{
	if (currentParser == NULL) {
		luaL_error(L, "invalid call to LoadFile() after execution");
	}

	const string filename = luaL_checkstring(L, 1);
	if (!LuaIO::IsSimplePath(filename)) {
		return 0;
	}
	string modes = luaL_optstring(L, 2, currentParser->accessModes.c_str());
	modes = CFileHandler::AllowModes(modes, currentParser->accessModes);

	CFileHandler fh(filename, modes);
	if (!fh.FileExists()) {
		lua_pushnil(L);
		lua_pushstring(L, "missing file");
		return 2;
	}
	string data;
	if (!fh.LoadStringData(data)) {
		lua_pushnil(L);
		lua_pushstring(L, "could not load data");
		return 2;
	}
	lua_pushstring(L, data.c_str());

	currentParser->accessedFiles.insert(StringToLower(filename));

	return 1;
}
コード例 #12
0
ファイル: UMcf.cpp プロジェクト: Translator5/desura-app
//checks the header and makes sure its a valid installer
bool UMcf::isValidInstaller()
{
    if (!m_sHeader->isValid())
        return false;

    if (m_sHeader->getType() != TYPE_APP)
        return false;

    FileHandle fh(m_szFile.c_str(), m_uiOffset);

    if(!fh.isValid())
        return false;

    uint32 count = 0;

    for(size_t x=0; x<m_pFileList.size(); x++)
    {
        if (!m_pFileList[x] || !m_pFileList[x]->isSaved())
            continue;

        if (!m_pFileList[x]->verifyFile(fh.hFileSrc, m_uiOffset))
        {
            printf("Not valid: %s\n", gcString(m_pFileList[x]->getName()).c_str());
            return false;
        }

        count++;
    }

    return (count != 0);
}
コード例 #13
0
ファイル: MapGenerator.cpp プロジェクト: 304471720/spring
void CMapGenerator::GenerateMapInfo(CVirtualArchive* archive)
{

	CVirtualFile* fileMapInfo = archive->AddFile("mapinfo.lua");

	//Open template mapinfo.lua
	const std::string luaTemplate = "mapgenerator/mapinfo_template.lua";
	CFileHandler fh(luaTemplate, SPRING_VFS_PWD_ALL);
	if(!fh.FileExists())
	{
		throw content_error("Error generating map: " + luaTemplate + " not found");
	}

	std::string luaInfo;
	fh.LoadStringData(luaInfo);

	//Make info to put in mapinfo
	std::stringstream ss;
	std::string startPosString;
	const std::vector<int2>& startPositions = GetStartPositions();
	for(size_t x = 0; x < startPositions.size(); x++)
	{
		ss << "[" << x << "] = {startPos = {x = " << startPositions[x].x << ", z = " << startPositions[x].y << "}},";
	}
	startPosString = ss.str();

	//Replace tags in mapinfo.lua
	boost::replace_first(luaInfo, "${NAME}", setup->mapName);
	boost::replace_first(luaInfo, "${DESCRIPTION}", GetMapDescription());
	boost::replace_first(luaInfo, "${START_POSITIONS}", startPosString);

	//Copy to filebuffer
	fileMapInfo->buffer.assign(luaInfo.begin(), luaInfo.end());
}
コード例 #14
0
ファイル: UnitDefHandler.cpp プロジェクト: Dmytry/spring
void CUnitDefHandler::LoadSound(GuiSoundSet& gsound,
                                const string& fileName, const float volume)
{
	CFileHandler raw(fileName);
	if (!sound->HasSoundItem(fileName) && !raw.FileExists())
	{
		string soundFile = "sounds/" + fileName;

		if (soundFile.find(".wav") == string::npos && soundFile.find(".ogg") == string::npos) {
			// .wav extension missing, add it
			soundFile += ".wav";
		}
		CFileHandler fh(soundFile);
		if (fh.FileExists()) {
			// we have a valid soundfile: store name, ID, and default volume
			const int id = sound->GetSoundId(soundFile);
			GuiSoundSet::Data soundData(fileName, id, volume);
			gsound.sounds.push_back(soundData);
		}
	}
	else
	{
		const int id = sound->GetSoundId(fileName);
		GuiSoundSet::Data soundData(fileName, id, volume);
		gsound.sounds.push_back(soundData);
	}
}
コード例 #15
0
void ParameterFile::regenerate(std::string workdir, std::string prevId, uint64_t gen) 
{
  std::ofstream fh(fullFileName, std::fstream::out); 

  std::stringstream ss; 
  ss << OutputFile::getFileBaseName(workdir) << "_parameters.run-"<< runid  << "." << prevId; 
  std::ifstream prevFile(ss.str()); 
  rejectIfNonExistant(ss.str()); 

  nat genFound = 0; 
  nat lineCtr = 0; 
  while(genFound < gen && not prevFile.eof())
    {
      std::string line; 
      getline(prevFile, line); 
      
      // hack =/ 
      bool lineIsEmpty = line.compare("") == 0 ; 
      
      if(lineCtr > 1 && not lineIsEmpty)
	{
	  std::stringstream ss1; 
	  ss1.str(line); 
	  std::string part; 
	  getline( ss1 ,part, '\t'  );       
	  genFound = std::stoi(part); 
	}

      if(genFound < gen && not lineIsEmpty)
	fh << line << std::endl; 
      ++lineCtr; 
    }

  fh.close();
} 
コード例 #16
0
ファイル: BranchInfo.cpp プロジェクト: Alasaad/Desurium
void BranchInfo::processInstallScript(TiXmlElement* scriptNode)
{
	int crc = 0;
	scriptNode->Attribute("crc", &crc);

	if (UTIL::FS::isValidFile(m_szInstallScript))
	{
		if (crc != 0 && m_uiInstallScriptCRC == (uint32)crc)
			return;
	}
	else
	{
		m_szInstallScript = UTIL::OS::getAppDataPath(gcWString(L"{0}\\{1}\\install_script.js", m_ItemId.getFolderPathExtension(), getBranchId()).c_str());
	}

	gcString base64 = scriptNode->GetText();

	try
	{
		UTIL::FS::recMakeFolder(UTIL::FS::Path(m_szInstallScript, "", true));
		UTIL::FS::FileHandle fh(m_szInstallScript.c_str(), UTIL::FS::FILE_WRITE);
		UTIL::STRING::base64_decode(base64, [&fh](const unsigned char* data, uint32 size) -> bool
		{
			fh.write((const char*)data, size);
			return true;
		});

		m_uiInstallScriptCRC = crc;
	}
	catch (gcException &e)
	{
		Warning(gcString("Failed to save install script for {0} branch {1}: {2}\n", m_ItemId.toInt64(), m_uiBranchId, e));
		m_szInstallScript = "";
	}
}
コード例 #17
0
ファイル: helper_image.hpp プロジェクト: Hopobcn/nbody
inline bool
sdkWriteFile(const char *filename, const T *data, unsigned int len,
             const S epsilon, bool verbose, bool append = false)
{
    assert(NULL != filename);
    assert(NULL != data);

    // open file for writing
    //    if (append) {
    std::fstream fh(filename, std::fstream::out | std::fstream::ate);

    if (verbose)
    {
        std::cerr << "sdkWriteFile() : Open file " << filename << " for write/append." << std::endl;
    }

    /*    } else {
            std::fstream fh(filename, std::fstream::out);
            if (verbose) {
                std::cerr << "sdkWriteFile() : Open file " << filename << " for write." << std::endl;
            }
        }
    */

    // check if filestream is valid
    if (! fh.good())
    {
        if (verbose)
        {
            std::cerr << "sdkWriteFile() : Opening file failed." << std::endl;
        }

        return false;
    }

    // first write epsilon
    fh << "# " << epsilon << "\n";

    // write data
    for (unsigned int i = 0; (i < len) && (fh.good()); ++i)
    {
        fh << data[i] << ' ';
    }

    // Check if writing succeeded
    if (! fh.good())
    {
        if (verbose)
        {
            std::cerr << "sdkWriteFile() : Writing file failed." << std::endl;
        }

        return false;
    }

    // file ends with nl
    fh << std::endl;

    return true;
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Khaon/android_system_extras
static int get_start(int mode, const std::string& filename)
{
    fec::io fh(filename, O_RDONLY, FEC_VERITY_DISABLE);

    if (!fh) {
        FATAL("failed to open input\n");
    }

    if (mode == MODE_GETECCSTART) {
        fec_ecc_metadata data;

        if (!fh.get_ecc_metadata(data)) {
            FATAL("no ecc data\n");
        }

        printf("%" PRIu64 "\n", data.start);
    } else {
        fec_verity_metadata data;

        if (!fh.get_verity_metadata(data)) {
            FATAL("no verity data\n");
        }

        printf("%" PRIu64 "\n", data.data_size);
    }

    return 0;
}
コード例 #19
0
ファイル: file.cpp プロジェクト: peredin/streams
/*!
 * \internal
 * Open an inode as a file.
 *
 * \warning Ownership of \a inode is assumed. Do not close or use
 *          it after a successful call to this function.
 *
 * \warning You must call file_close on the returned handle, otherwise
 *          memory will be leaked.
 *
 * \param  inode  a pointer to the file inode
 * \return        a pointer to a file_handle
 *
 */
file_handle* file_open(inode* inode)
{
	if (!inode)
		throw std::invalid_argument("file_open  null arg: inode");

	debug::tracer DT;
	DT << "opening file from pre-opened inode " << inode->ino;

	if (ITYPE_FILE != inode->data.f_type)
		throw fs_error(ERROR_NOTDIR);

	assert(inode->fs);

	std::unique_ptr< file_handle > fh(new file_handle);

	fh->inode = inode;
	fh->pos = 0;

	fh->rw_buf.resize(inode->fs->blocksize);
	fh->rw_buf_lblockno = 0;
	fh->rw_buf_pblockno = 0;
	fh->rw_buf_valid = false;
	fh->rw_buf_dirty = false;

	return fh.release();
}
コード例 #20
0
int PostMetaStrategy::Execute(FileManager* fm, CredentialsManager* cm) {
    int status = ret::A_OK;
    status = InitInstance(fm, cm);

    post_path_ = GetConfigValue("post_path");
    posts_feed_ = GetConfigValue("posts_feed");
    std::string filepath = GetConfigValue("filepath");
    std::string entity = GetConfigValue("entity");

    std::cout<<" Post meta strategy " << std::endl;
    if(ValidMasterKey()) {
        FileHandler fh(file_manager_);
        if(!fh.DoesFileExist(filepath)) {
            std::cout<<" File doesn't exist yet, create meta post" << std::endl;
            FileInfo fi;
            status = CreateFileEntry(filepath, fi);
        }
        else {
           // no nead to throw an error, postfilestrategy should dif the hashes 
           // and really determine if it should acutally be re-uploaded
           //
           // status = ret::A_FAIL_FILE_ALREADY_EXISTS;
        }
    }
    else {
        status = ret::A_FAIL_INVALID_MASTERKEY;
    }
    std::cout<<" post meta strategy status : " << status << std::endl;
    return status;
}
コード例 #21
0
ファイル: Bchart.C プロジェクト: chrisleewashere/SwiRL-OSX
float
Bchart::
meEdgeProb(const Term* trm, Edge* edge, int whichInt)
{
  FullHist fh(edge);
  float ans =  meFHProb(trm, fh, whichInt);
  return ans;
}
コード例 #22
0
ファイル: McfTest.cpp プロジェクト: aromis/desura-app
	void createFile(const char* szFileName, const char* szData)
	{
        auto path = UTIL::FS::PathWithFile(szFileName);

        UTIL::FS::recMakeFolder(path);

        UTIL::FS::FileHandle fh(path, UTIL::FS::FILE_WRITE);
        fh.write(szData, strlen(szData));
	}
コード例 #23
0
int PostMetaStrategy::CreateFileEntry(const std::string& filepath, FileInfo& out) {
    int status = ret::A_OK;
    std::cout<<" creating file entry : " << filepath << std::endl;
    std::string mk;
    GetMasterKey(mk);
    FileHandler fh(file_manager_);
    if(!fh.CreateNewFile(filepath, mk, posts_feed_, access_token_, out))
        status = ret::A_FAIL_CREATE_FILE_INFO;
    return status;
}
コード例 #24
0
ファイル: User.cpp プロジェクト: Alasaad/Desurium
void User::testMcfCache()
{
	UTIL::FS::Path p(m_szMcfCachePath, "temp", false);
	UTIL::FS::FileHandle fh(p, UTIL::FS::FILE_WRITE);

	fh.write("1234", 4);
	fh.close();

	UTIL::FS::delFile(p);
}
コード例 #25
0
ファイル: HalfEdgeMesh.cpp プロジェクト: Ultimaker/Atlas
void HE_Mesh::checkModel(std::vector<ModelProblem>& problems)
{
    for (int f = 0; f < faces.size(); f++)
    {
        if (faces[f].edge_idx[0] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; }
        if (faces[f].edge_idx[1] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; }
        if (faces[f].edge_idx[2] < 0) { problems.emplace_back("face doesn't know its edges! : " + std::to_string(f)); continue; }
        HE_FaceHandle fh(*this, f);
        if (fh.edge0().next() != fh.edge1()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f));
        if (fh.edge1().next() != fh.edge2()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f));
        if (fh.edge2().next() != fh.edge0()) problems.emplace_back("disconnected prev-next edges : " + std::to_string(f));
        if (fh.edge0().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f));
        if (fh.edge1().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f));
        if (fh.edge2().face() != fh) problems.emplace_back("face's edge not connected to face : " + std::to_string(f));
    }
    for (int e = 0; e < edges.size(); e++)
    {
        bool hasNull = false;
        if(edges[e].from_vert_idx < 0) { problems.emplace_back("edge doesn't know its vert! : " + std::to_string(e)); hasNull = true; }
        if(edges[e].next_edge_idx < 0) { problems.emplace_back("edge doesn't know its next edge! : " + std::to_string(e)); hasNull = true; }
        if(edges[e].converse_edge_idx < 0) { problems.emplace_back("edge doesn't know its converse! : " + std::to_string(e)); hasNull = true; }
        if(edges[e].face_idx < 0) { problems.emplace_back("edge doesn't know its face! : " + std::to_string(e)); hasNull = true; }
        if (hasNull) continue;

        HE_EdgeHandle eh(*this, e);
        if(eh.converse().converse() != eh) problems.emplace_back("edge isn't the converse of its converse : " + std::to_string(e));

        int counter = 0;
        HE_EdgeHandle eh2 = eh;
        do
        {
            if (counter > MAX_EDGES_PER_VERTEX) {
                problems.emplace_back("edges don't form a circular loop! : " + std::to_string(e)); break; } // continue outer for-loop
            eh2 = eh2.converse().next(); counter++;
        } while (eh2 != eh);
        // dont put more code here
    }
    for (int v = 0; v < vertices.size(); v++)
    {
        if (vertices[v].someEdge_idx < 0) { problems.emplace_back("vertex doesn't know any edge! : " + std::to_string(v)); continue; }
        HE_VertexHandle vh(*this, v);

// done for each edge!
//        int counter = 0;
//        HE_EdgeHandle eh = vh.someEdge();
//        do
//        {
//            if (counter > MAX_EDGES_PER_VERTEX) { problems.emplace_back("vertex edges don't form a circular loop!"); break; } // continue outer for-loop
//            eh = eh.converse().next(); counter++;
//        } while (eh != vh.someEdge());
//        // dont put more code here
    }


}
コード例 #26
0
//*************************************************************************************
//
//*************************************************************************************
void	CTraceRecorder::AbortTrace()
{
	DAEDALUS_PROFILE( "CTraceRecorder::AbortTrace" );

	if( mTracing )
	{
#ifdef LOG_ABORTED_TRACES
		FILE * fh( fopen( "aborted_traces.txt", "a" ) );
		if(fh)
		{
			fprintf( fh, "\n\nTrace: (%d ops)\n", mTraceBuffer.size() );

			u32		last_address( mTraceBuffer.size() > 0 ? mTraceBuffer[ 0 ].Address-4 : 0 );
			for(std::vector< STraceEntry >::const_iterator it = mTraceBuffer.begin(); it != mTraceBuffer.end(); ++it)
			{
				u32		address( it->Address );
				OpCode	op_code( it->OpCode );
				u32		branch_index( it->BranchIdx );

				if( branch_index != INVALID_IDX )
				{
					DAEDALUS_ASSERT( branch_index < mBranchDetails.size(), "The branch index is out of range" );

					const SBranchDetails &	details( mBranchDetails[ branch_index ] );

					fprintf( fh, " BRANCH %d -> %08x\n", branch_index, details.TargetAddress );
				}

				char		buf[100];
				SprintOpCodeInfo( buf, address, op_code );

				bool		is_jump( address != last_address + 4 );

				fprintf( fh, "%08x: %c%s\n", address, is_jump ? '*' : ' ', buf );

				last_address = address;
			}

			fclose(fh);
		}
#endif


		//DBGConsole_Msg( 0, "Aborting tracing of     [R%08x]", mStartTraceAddress );
		mTracing = false;
		mStartTraceAddress = 0;
		mTraceBuffer.clear();
		mBranchDetails.clear();
		mExpectedExitTraceAddress = 0;
		mActiveBranchIdx = INVALID_IDX;
		mStopTraceAfterDelaySlot = false;
		mNeedIndirectExitMap = false;
	}

}
コード例 #27
0
ファイル: CBinaryBayes.cpp プロジェクト: ciri/code-examples
void CBinaryBayes::saveModel(std::string fileName) {
	std::ofstream fh (fileName.c_str());
	//Output general info on first line
	fh << this->m <<" "<<this->Cpos <<" "<<this->Cneg <<" "<<this->prior<<" "<<this->allZeroSumPos<<" "<<this->allZeroSumNeg<<"\n";

	//Output class probabilities line per line
	for(int i = 0; i < m; i++) {
		fh <<  this->isKnown[i]<<" "<<this->P0P[i]<<" "<<this->P0N[i] <<" "<<this->P1P[i]<<" "<<this->P1N[i]<<"\n";
	}
	fh.close();
}
コード例 #28
0
ファイル: zip_resource.cpp プロジェクト: AMDmi3/Vangers
void XZIP_Resource::dump(char* fname)
{
	XZIP_FileHeader* p = fileList.first();

	XStream fh(fname,XS_OUT);
	while(p){
		fh < p -> name() < " " <= p -> size() < "/" <= p -> offset() < "\r\n";
		p = p -> next;
	}
	fh.close();
}
コード例 #29
0
ファイル: 0.c プロジェクト: nee47/backup
bool hash_pertenece(const hash_t *hash, const char *clave){
  unsigned long indice = fh(clave, hash->largo);
  if (!hash->tabla[indice]) return false;
  lista_iter_t* iter_l = busqueda(hash->tabla[indice], clave);
  if (lista_iter_al_final(iter_l)) {
    lista_iter_destruir(iter_l);
    return false;
  }
  lista_iter_destruir(iter_l);
  return true;
}
コード例 #30
0
    prot::FileHandle
    DummySessionConnection::open_file(const boost::filesystem::path& filename)
    {
      if (!open_file_error.empty())
        throw std::runtime_error(open_file_error);

      opened_files.push_back(filename);
      prot::FileHandle fh(opened_files.size() - 1);
      fh_to_idx[fh] = opened_files.size() - 1;
      return fh;
    }