Пример #1
0
 /*! \brief load and initialize the iterator with fi */
 inline void LoadBinary(utils::FileStream &fi,
                        bool silent,
                        const char *fname_) {
   this->set_cache_file(fname_);
   std::string fname = fname_;
   int tmagic;
   utils::Check(fi.Read(&tmagic, sizeof(tmagic)) != 0, "invalid input file format");
   this->CheckMagic(tmagic);
   this->info.LoadBinary(fi);
   // load in the row data file
   fname += ".row.blob";
   utils::FileStream fs(utils::FopenCheck(fname.c_str(), "rb"));
   iter_->Load(fs);
   if (!silent) {
     utils::Printf("DMatrixPage: %lux%lu matrix is loaded",
                   static_cast<unsigned long>(info.num_row()),
                   static_cast<unsigned long>(info.num_col()));
     if (fname_ != NULL) {
       utils::Printf(" from %s\n", fname_);
     } else {
       utils::Printf("\n");
     }
     if (info.group_ptr.size() != 0) {
       utils::Printf("data contains %u groups\n", (unsigned)info.group_ptr.size() - 1);
     }
   }
 }
Пример #2
0
	void NewsCache::Load()
	{
		Utils::FileStream fs;
		fs.Open(Core::cfg.GetCfgDir() + '/' + Core::cfg.GetMotdFile());
		uint size = (uint)fs.Size();
		_motd.resize(size);
		fs.Read(&_motd[0], size);
		fs.Close();
		LOG_DEBUG(("Loaded motd: %s", _motd.c_str()));

		std::string content;
		fs.Open(Core::cfg.GetCfgDir() + '/' + Core::cfg.GetNewsFile());
		size = (uint)fs.Size();
		content.resize(size);
		fs.Read(&content[0], size);

		uint i = 0;
		while(i + 1 < content.length() && (content[i] != '{' || content[i + 1] != '{'))
			++ i;
		if(i + 1 < content.length())
			i += 2;
		while(i + 1< content.length())
		{
			uint start = i;
			while(i + 1 < content.length() && (content[i] != '}' || content[i + 1] != '}'))
				++ i;
			if(i + 1 >= content.length())
				break;
			std::string date(content.begin() + start, content.begin() + i);
			i += 2;
			while(i < content.length() && (content[i] == '\r' || content[i] == '\n'))
				++ i;
			if(i >= content.length())
				break;
			start = i;
			while(i + 1 < content.length() && (content[i] != '{' || content[i + 1] != '{'))
				++ i;
			uint end = i;
			while(end > start && (content[end - 1] == '\r' || content[end - 1] == '\n'))
				-- end;
			Add(date, std::string(content.begin() + start, content.begin() + end));
			if(i + 1 < content.length())
				i += 2;
			else
				break;
		}
	}
Пример #3
0
	XmlNode::XmlNode( const char * filename )
	{
		_parent = NULL;
		_data = NULL;
		Utils::FileStream fs;
		if(!fs.Open(filename))
			return;
		uint size = (uint)fs.Size();
		if(size == 0)
			return;
		std::string buf;
		buf.resize(size);
		fs.Read(&buf[0], size);
		fs.Close();
		mxml_node_t * root = mxmlLoadString(NULL, &buf[0], NULL);
		_data = root;
	}
Пример #4
0
	FileCacheItem::FileCacheItem( Utils::FileStream& fs )
	{
		uint size = (uint)fs.Size();
		_data.append_zero(size);
		fs.Read(&_data[0], size);
	}