Esempio n. 1
0
bool FileSystemManager::removeObject(Watchable *listener)
{
	int indx = vecContains(listenerList, listener);

	if (indx != -1)
	{
		StrList watchDirs = listener->getWatchDir();

		// Remove it from the directory watcher
		for (uint i = 0; i < watchDirs.size(); i++)
			dirWatcher.UnwatchDirectory((LPCTSTR) watchDirs[i].utf16());

		// Kill off any events that belong to this directory
		for (int i = 0; i < eventList.size(); i++)
		{
			if (eventList[i].obj == listener)
			{
				eventList.erase(eventList.begin() + i);
				i--;
			}
		}

		// Remove the watchable item from our own list
		listenerList.erase(listenerList.begin() + indx);
		return true;
	}

	return false;
}
void V3PreProcImp::openFile(FileLine* fl, V3InFilter* filterp, const string& filename) {
    // Open a new file, possibly overriding the current one which is active.
    V3File::addSrcDepend(filename);

    // Read a list<string> with the whole file.
    StrList wholefile;
    bool ok = filterp->readWholefile(filename, wholefile/*ref*/);
    if (!ok) {
	error("File not found: "+filename+"\n");
	return;
    }

    if (!m_preprocp->isEof()) {  // IE not the first file.
	// We allow the same include file twice, because occasionally it pops
	// up, with guards preventing a real recursion.
	if (m_lexp->m_streampStack.size()>V3PreProc::INCLUDE_DEPTH_MAX) {
	    error("Recursive inclusion of file: "+filename);
	    return;
	}
	// There's already a file active.  Push it to work on the new one.
	addLineComment(0);
    }

    // Create new stream structure
    m_lexp->scanNewFile(m_preprocp->fileline()->create(filename, 1));
    addLineComment(1); // Enter

    // Filter all DOS CR's en-mass.  This avoids bugs with lexing CRs in the wrong places.
    // This will also strip them from strings, but strings aren't supposed to be multi-line without a "\"
    for (StrList::iterator it=wholefile.begin(); it!=wholefile.end(); ++it) {
	// We don't end-loop at \0 as we allow and strip mid-string '\0's (for now).
	bool strip = false;
	const char* sp = it->data();
	const char* ep = sp + it->length();
	// Only process if needed, as saves extra string allocations
	for (const char* cp=sp; cp<ep; cp++) {
	    if (VL_UNLIKELY(*cp == '\r' || *cp == '\0')) {
		strip = true; break;
	    }
	}
	if (strip) {
	    string out;  out.reserve(it->length());
	    for (const char* cp=sp; cp<ep; cp++) {
		if (!(*cp == '\r' || *cp == '\0')) {
		    out += *cp;
		}
	    }
	    *it = out;
	}

	// Push the data to an internal buffer.
	m_lexp->scanBytesBack(*it);
	// Reclaim memory; the push saved the string contents for us
	*it = "";
    }
}
Esempio n. 3
0
/*
 Must LockFileQueue() first,
 and UnlockFileQueue() after finished opertion.
 */
string PopFile()
{
    if(s_fileList.size() == 0)
        return "";
    
    string ret;
    ret = s_fileList.front();
    s_fileList.pop_front();
    
    return ret;
}
Esempio n. 4
0
string PredefinedInspector::getProcStatus(const PropertyList& argList,
    string& contentType)
{
    contentType = "text/plain";

    StrList strList;
    if (strList.loadFromFile("/proc/self/status"))
        return strList.getText();
    else
        return "";
}
Esempio n. 5
0
string PredefinedInspector::getBasicInfo(const PropertyList& argList,
    string& contentType)
{
    contentType = "text/plain";

    StrList strList;
    strList.add(formatString("path: %s", getAppExeName().c_str()));
    strList.add(formatString("pid: %d", ::getpid()));

    return strList.getText();
}
Esempio n. 6
0
void TripodClient::GetList(const std::string& key, StrList& value, int begin, int limit) {
  RedisCacheClientPtr client = GetRedisCacheClient();
  if (!client) {
    MCE_INFO("TripodClient::GetList() RedisCacheClient is NULL");
    return;
  }
  const StrList& list = client->GetList(key, begin, limit, namespaceId_, businessId_);
  if (!list.empty()) {
    value.insert(value.end(), list.begin(), list.end());
  }
}
Esempio n. 7
0
void FileSystemManager::onPowerSuspend()
{
	// unwatch all the directories
	for (int i = 0; i < listenerList.size(); ++i)
	{
		Watchable * w = listenerList[i];

		StrList watchDirs = w->getWatchDir();
		for (int j = 0; j < watchDirs.size(); j++)
			dirWatcher.UnwatchDirectory((LPCTSTR) watchDirs[j].utf16());
	}
}
Esempio n. 8
0
int UpdateTagsFile(const char* file)
{
  TagFileInfo *fi=NULL;
  int i;
  String filename=file;
  filename.ToLower();
  for(i=0;i<files.Count();i++)
  {
    if(files[i]->filename==filename)
    {
      fi=files[i];
      break;
    }
  }
  if(!fi)
  {
    struct stat st;
    if(stat(filename,&st)==-1)return 0;
    TagFileInfo tfi;
    tfi.filename=filename;
    tfi.modtm=st.st_mtime;
    if(!FindIdx(&tfi))return 0;
    if(Load(filename,"")!=1)return 0;
  }
  StrList sl;
  if(!CheckChangedFiles(filename,sl))return 0;
  if(sl.Count()==0)return 1;
  sl.SaveToFile("tags.changes");
  String cmd=config.exe+" ";
  String opt=config.opt;
  opt.Replace("-R","");
  RegExp re("/\\*(\\.\\S*)?/");
  SMatch m[4];
  int n=4;
  while(re.Search(opt,m,n))
  {
    opt.Delete(m[0].start,m[0].end-m[0].start);
  }
  cmd+=opt;
  cmd+=" -f tags.update -L tags.changes";
  //extern int Msg(const char* err);
  //Msg(cmd);
  if(!Execute(cmd))
  {
    remove("tags.changes");
    return 0;
  }
  MergeFiles(file,"tags.update");
  remove("tags.changes");
  remove("tags.update");
  Load(file,"");
  return 1;
}
Esempio n. 9
0
void LocalPhotoFrameSource::updateDirectory(QDir dir, vector<PhotoFrameSourceItem>& items)
{
	// assume dir exists
	if (!empty(dir))
	{
		StrList dirListing = fsManager->getDirectoryContents(native(dir));
		for (int i = 0; i < dirListing.size(); ++i)
		{
			QFileInfo file(dirListing[i]);

			if (file.isSymLink()) {
				file = QFile(file.symLinkTarget());
			}

			if (file.isDir())
				// recurse into that directory
				updateDirectory(file.absoluteFilePath(), items);
			else
			{
				// XXX: we can do this smarter with watched directories?!

				// check if this is a valid image file
				QString filename = file.fileName();
				if (filename.size() > 4)
				{
					QString ext = fsManager->getFileExtension(filename);
					bool isValidImage = !ext.isEmpty() && GLOBAL(supportedExtensions).contains(ext + ".");
					if (isValidImage)
					{
						// check if we already have that item in the list
						vector<PhotoFrameSourceItem>::const_iterator itemIter = items.begin();
						vector<PhotoFrameSourceItem>::const_iterator endIter = items.end();
						bool exists = false;
						while (itemIter != endIter)
						{
							if ((*itemIter).getResourceId() == dirListing[i])
								exists = true;
							++itemIter;
						}

						// if not, add it to the list
						if (!exists)
						{
							PhotoFrameSourceItem item(dirListing[i]);
							item.setTexturePath(dirListing[i]);
							items.push_back(item);
						}
					}
				}
			}
		}
	}
}
Esempio n. 10
0
void FileSystemManager::onPowerResume()
{
	// re-watch all the directories
	for (int i = 0; i < listenerList.size(); ++i)
	{
		Watchable * w = listenerList[i];

		uint changeFilter = FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_ATTRIBUTES;
		StrList watchDirs = w->getWatchDir();
		for (int j = 0; j < watchDirs.size(); j++)
			dirWatcher.WatchDirectory((LPCTSTR) watchDirs[j].utf16(), changeFilter, this);
	}
}
void EventsGenerator::desiresCB(const hbba_msgs::DesiresSet::ConstPtr& msg)
{
	typedef std::vector<std::string> StrVec;
	typedef std::list<std::string> StrList;
	typedef std::vector<hbba_msgs::Desire> DesVec;
	typedef std::map<std::string,std::string> TypeMap;
	const DesVec& desires = msg->desires;
	TypeMap typeMap;
	StrVec ids;
	ids.reserve(desires.size());
	for (DesVec::const_iterator d = desires.begin(); d != desires.end(); ++d)
	{
		ids.push_back(d->id);
		typeMap[d->id] = d->type;
	}

    // First, remove desires not in it the current desires set.
    StrList del;
    for (Model::const_iterator i = model_.begin(); i != model_.end(); ++i)
    {
        const std::string& id = i->first;
        if (std::find(ids.begin(), ids.end(), id) == ids.end())
            del.push_back(id);
    }
    for (StrList::const_iterator i = del.begin(); i != del.end(); ++i)
    {
        const std::string& id = *i;
	
        event(id, model_[id].type, hbba_msgs::Event::DES_OFF);
        if (model_[id].flags & FLAG_INT)
            event(id, model_[id].type, hbba_msgs::Event::INT_OFF);
        if (model_[id].flags & FLAG_EXP)
            event(id, model_[id].type, hbba_msgs::Event::EXP_OFF);

        model_.erase(id);
    }

	// Then, generate events for new desires.
	for (StrVec::const_iterator i = ids.begin(); i != ids.end(); ++i)
	{
		const std::string& id = *i;
		if (model_.find(id) == model_.end())
		{
			model_[id].flags = FLAG_NONE;
			model_[id].type = typeMap[id]; //set type in the model
			event(id, model_[id].type, hbba_msgs::Event::DES_ON);
		}
	}

}
Esempio n. 12
0
// Example: /category/command?arg1=value&arg2=value
bool IseServerInspector::parseCommandUrl(const HttpRequest& request,
    string& category, string& command, PropertyList& argList)
{
    bool result = false;
    string url = request.getUrl();
    string argStr;
    StrList strList;

    if (!url.empty() && url[0] == '/')
        url.erase(0, 1);

    // find the splitter char ('?')
    string::size_type argPos = url.find('?');
    bool hasArgs = (argPos != string::npos);
    if (hasArgs)
    {
        argStr = url.substr(argPos + 1);
        url.erase(argPos);
    }

    // parse the string before the '?'
    splitString(url, '/', strList, true);
    if (strList.getCount() >= 2)
    {
        category = strList[0];
        command = strList[1];
        result = true;
    }

    // parse the args
    if (result)
    {
        argList.clear();
        splitString(argStr, '&', strList, true);
        for (int i = 0; i < strList.getCount(); ++i)
        {
            StrList parts;
            splitString(strList[i], '=', parts, true);
            if (parts.getCount() == 2 && !parts[0].empty())
            {
                argList.add(parts[0], parts[1]);
            }
        }
    }

    return result;
}
Esempio n. 13
0
Variable::Variable( const StrList &lst )
{
    if( lst.getSize() == 1 )
    {
        eType = typeString;
        uVal.sVal = new Bu::String( lst.first() );
    }
    else
    {
        eType = typeList;
        uVal.lVal = new VarList();
        for( StrList::const_iterator i = lst.begin(); i; i++ )
        {
            uVal.lVal->append( Variable( *i ) );
        }
    }
}
Esempio n. 14
0
void CleanUpPakDirs()
{
  ClearPaKDir(&paktextures);
  paktextures = NULL;
  dirhead = NULL;
  g_PK3TexturePaths.RemoveAll();
  g_PK3Files.RemoveAll();
}
Esempio n. 15
0
void FindParts(const char* file, const char* part,StrList& dst)
{
  String filename=file;
  filename.ToLower();
  dst.Clean();
  StrList tmp;
  int i;
  for(i=0;i<files.Count();i++)
  {
    if(files[i]->mainaload ||
       files[i]->isLoadBase(filename))
    {
      FindPartsInFile(files[i],part,tmp);
    }
  }
  if(tmp.Count()==0)return;
  tmp.Sort(dst);
  i=1;
  String *s=&dst[0];
  while(i<dst.Count())
  {
    if(dst[i]==*s)
    {
      dst.Delete();
    }else
    {
      s=&dst[i];
      i++;
      if(i==dst.Count())break;
    }
  }
}
Esempio n. 16
0
//-----------------------------------------------------------------------------
// 描述: 取得当前记录中某个字段的数据
// 参数:
//   name - 字段名
//-----------------------------------------------------------------------------
DbField* DbDataSet::getFields(const string& name)
{
    int index = dbFieldDefList_.indexOfName(name);

    if (index >= 0)
        return getFields(index);
    else
    {
        StrList fieldNames;
        dbFieldDefList_.getFieldNameList(fieldNames);
        string fieldNameList = fieldNames.getCommaText();

        string errMsg = formatString(SEM_FIELD_NAME_ERROR, name.c_str(), fieldNameList.c_str());
        iseThrowDbException(errMsg.c_str());
    }

    return NULL;
}
void ProductRankerTestFixture::convertMerchantId_(
    const std::string& merchantList,
    PropValueIdList& idList)
{
    typedef std::vector<std::string> StrList;
    StrList strList;
    split_str_to_items(merchantList, strList);

    for (StrList::const_iterator it = strList.begin(); it != strList.end(); ++it)
    {
        merchant_id_t merchantId = 0;
        std::vector<izenelib::util::UString> path;
        path.push_back(izenelib::util::UString(*it, ENCODING_TYPE));

        merchantId = merchantValueTable_.insertPropValueId(path);
        idList.push_back(merchantId);
    }
}
Esempio n. 18
0
Watchable *FileSystemManager::getWatchObjFromPath(QString filePath)
{
	for (uint i = 0; i < listenerList.size(); i++)
	{
		StrList watchDirs = listenerList[i]->getWatchDir();
		for (uint k = 0; k < watchDirs.size(); k++)
		{
			// If this directory query is contained in our listener list, return true
			if ((watchDirs[k] == filePath) ||
				(watchDirs[k] == (filePath + "\\")))
			{
				return listenerList[i];
			}
		}
	}

	return NULL;
}
Esempio n. 19
0
/*
 Must LockFileQueue() first,
 and UnlockFileQueue() after finished opertion.
 */
StrList::iterator InsertDir(const string& strDirPath,
                            bool fInsertFront, bool fAddSubDir)
{
    StrList::iterator itrFile;
    if(fInsertFront)
        itrFile = s_fileList.begin();
    else
        itrFile = --s_fileList.end();
    
    DIR *pDir;
    struct dirent *pDirent;
    
    pDir = opendir(strDirPath.c_str());
    if(pDir)
    {
        struct stat fileStat;
        while((pDirent = readdir(pDir)) != NULL)
        {
            string strPath(pDirent->d_name);
            if(strPath != "." && strPath != "..")
            {
                if(strDirPath[strDirPath.length() - 1] == '/')
                    strPath = strDirPath + strPath;
                else
                    strPath = strDirPath + "/" + strPath;
                
                if(strPath.find(".DS_Store") != string::npos ||
                   strPath.find(".Trashes") != string::npos ||
                   strPath.find(".TemporaryItems") != string::npos)
                    continue;
                
                stat(strPath.c_str(), &fileStat);
                if((fileStat.st_mode & S_IFREG) ||
                   ((fileStat.st_mode & S_IFDIR) && fAddSubDir))
                    itrFile = InsertFile(strPath, itrFile);
            }
        }
        
        closedir(pDir);
    }

    return itrFile;
}
Esempio n. 20
0
boolean GetPackTextureDirs(DIRLIST **dirlist)
{
	UInt16					i;
	char					buf[57];

	if (!pakopen)
		return 1;

  if (g_bPK3)
  {
    StrList *pl = g_PK3TexturePaths.Next();
    while (pl != NULL)
    {
      AddToDirListAlphabetized(dirlist, pl->Ref(), 0);
      pl = pl->Next();
    }
    return true;
  }

	for (i = 0; i < dirsize; i++)
	{
		if(!strnicmp(pakdirptr[i].name, "textures", 8))
		{
			strncpy(buf, &(pakdirptr[i].name[9]), 46);
			if(strchr(buf, '\\'))
	      	*strchr(buf, '\\') = '\0';
			else if(strchr(buf, '/'))
	      	*strchr(buf, '/') = '\0';
			else
	      	buf[56] = '\0';

			if(strchr(buf, '.'))
				continue;

			AddToDirListAlphabetized(dirlist, buf, 0);
		}
	}
	return true;
}
Esempio n. 21
0
void FlickrPhotoFrameSource::requestSourceUpdate()
{
	// just load the images from cache if there is no internet connection
	if (!ftManager->hasInternetConnection())
		loadPhotosFromCache();

	// ensure we have a valid flickr source
	if (!isValidFlickrPhotoFrame())
		return;

	// remove existing downloads
	ftManager->removeTransfersToHandler(this);

	// See how many photos we currently have cached
	int maxNumFilesToCache = 64;
	createLocalCacheDirectory();
	StrList filesToDelete = fsManager->getDirectoryContents(native(_localCacheDirectory));
	if (filesToDelete.size() > maxNumFilesToCache)
	{
		for (int i = 0; i < filesToDelete.size(); ++i)
		{
			QFile::remove(filesToDelete[i]);
		}
	}

	// Determine what kind of photos to download
	// The order is important here since both getting photos from favourite
	// and getting photos from a specific user both involve the same parameter
	FlickrClient flickrClient(FLICKR_AUTH_TOKEN);
	if (_rssFeedUrl.contains("photos_faves"))
		flickrClient.requestFavouritePhotosFromId(_userId, this);
	else if (!_userId.isEmpty())
		flickrClient.requestPhotosFromId(_userId, false, this);
	else if (!_groupId.isEmpty())
		flickrClient.requestPhotosFromId(_groupId, true, this);
	else
		flickrClient.requestPhotosByTag(_tag, this);
}
Esempio n. 22
0
bool FileSystemManager::addObject(Watchable *listener)
{
	uint changeFilter = FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_ATTRIBUTES;

	// Check if this item is not part of the listener list
	if (vecContains(listenerList, listener) == -1)
	{
		StrList watchDirs = listener->getWatchDir();

		// Add this directory to the watch list
		for (uint i = 0; i < watchDirs.size(); i++)
		{
			dirWatcher.WatchDirectory((LPCTSTR) watchDirs[i].utf16(), changeFilter, this);
		}

		listenerList.push_back(listener);

		return true;
	}

	// Item is already in the list
	return false;
}
Esempio n. 23
0
string PredefinedInspector::getBasicInfo(const PropertyList& argList,
    string& contentType)
{
    contentType = "text/plain";

    DWORD procId = ::GetCurrentProcessId();
    HANDLE handle = ::OpenProcess(PROCESS_QUERY_INFORMATION, false, procId);
    size_t memorySize = 0;

    PROCESS_MEMORY_COUNTERS pmc = {0};
    pmc.cb = sizeof(pmc);
    if (::GetProcessMemoryInfo(handle, &pmc, pmc.cb))
        memorySize = pmc.WorkingSetSize;

    ::CloseHandle(handle);

    StrList strList;
    strList.add(formatString("path: %s", getAppExeName().c_str()));
    strList.add(formatString("pid: %u", procId));
    strList.add(formatString("memory: %s bytes", addThousandSep(memorySize).c_str()));

    return strList.getText();
}
Esempio n. 24
0
StrList	FileSystemManager::getWorkingDirectoryContents(QString filter)
{
	if (!scnManager->getCurrentLibrary())
		return getDirectoryContents(native(scnManager->getWorkingDirectory()), filter);
	
	StrList files;
	QListIterator<QString> dirIt(scnManager->getCurrentLibrary()->getFolderPaths());
	while (dirIt.hasNext())
	{
		StrList list = getDirectoryContents(dirIt.next(), filter);
		files.insert(files.end(), list.begin(), list.end());
	}
	return files;
}
Esempio n. 25
0
void get_history(StrList& history, const char* cmdFifo, const char* listFifo)
{
  char  current[256];
  if (!getcwd(current, sizeof(current)-1))
    current[0] = '\0';

  String buf(":list:");
  buf += current;
  buf += '\n';

  ofstream  daemon(cmdFifo);
  daemon << buf;
  daemon.close();

  ifstream  in(listFifo);

  while (getline(in, buf).good()) {
    history.push_back(buf);
  }
} // end get_history
Esempio n. 26
0
void CViewMsgDlg::OnMenuQuickReply() 
{
#define IDM_QUICK_REPLY	1000
	
	CMenu menu;
	menu.CreatePopupMenu();

	IcqOption &options = icqLink->options;
	StrList l;
	IcqDB::loadQuickReply(l);
	StrList::iterator it;
	UINT id = IDM_QUICK_REPLY;

	CString str;
	for (it = l.begin(); it != l.end(); ++it) {
		CString str = (*it).c_str();
		if (str.GetLength() > 20)
			str = str.Left(20) + "...";
		menu.AppendMenu(
			str == options.quickReplyText.c_str() ? MF_CHECKED : MF_UNCHECKED,
			id++, str);
	}
	str.LoadString(IDS_QUICK_REPLY_SETTING);
	menu.AppendMenu(MF_STRING, id++, str);

	CRect rc;
	GetDlgItem(IDC_MENU_QUICK_REPLY)->GetWindowRect(rc);
	id = menu.TrackPopupMenu(TPM_RETURNCMD, rc.left, rc.bottom, this);
	if (id == 0)
		return;

	id -= IDM_QUICK_REPLY;
	if (id == menu.GetMenuItemCount() - 1)
		((CIcqDlg *) AfxGetMainWnd())->showOptions(1);
	else {
		int i = 0;
		for (it = l.begin(); it != l.end() && i < id; ++it, ++i)
			;
		if (it != l.end()) {
			options.quickReplyText = *it;
			IcqDB::saveOptions(options);
			OnQuickReply();
		}
	}
}
Esempio n. 27
0
/*
 Must LockFileQueue() first,
 and UnlockFileQueue() after finished opertion.
 */
StrList::iterator InsertFile(const string& strFilePath,
                             StrList::const_iterator itrWhere)
{
    return s_fileList.insert(itrWhere, strFilePath);
}
Esempio n. 28
0
//-----------------------------------------------------------------------------
// 描述: 返回全部字段名
//-----------------------------------------------------------------------------
void DbFieldDefList::getFieldNameList(StrList& list)
{
    list.clear();
    for (int i = 0; i < items_.getCount(); i++)
        list.add(((DbFieldDef*)items_[i])->getName().c_str());
}
Esempio n. 29
0
int CMsgTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTreeView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	CTreeCtrl &tree = GetTreeCtrl();
	tree.SetImageList(&getApp()->smallImageList, TVSIL_NORMAL);
	tree.SetItemHeight(24);

	IcqUser &myInfo = icqLink->myInfo;
	CString str;
	str.Format("%s(%s)", myInfo.qid.toString(), myInfo.nick.c_str());
	HTREEITEM root = tree.InsertItem(str, getApp()->getFaceIndex(myInfo.face),
		getApp()->getFaceIndex(myInfo.face, STATUS_AWAY), NULL);

	MyICQCtrl &outbar = ((CIcqDlg *) AfxGetMainWnd())->outbarCtrl;
	int n = outbar.getFolderCount();
	QID *qid;
	CString name;
	int image;
	HTREEITEM stranger = NULL;

	StrList qidList;
	IcqDB::getMsgQIDList(qidList);

	for (int i = 0; i < n; ++i) {
		outbar.getFolderName(i, name);
		image = getApp()->iconIndex(ICON_FOLDER);
		HTREEITEM parent = tree.InsertItem(name, image, image, root);

		int nrItems = outbar.getItemCount(i);
		for (int j = 0; j < nrItems; ++j) {
			IcqContact *c = outbar.contact(i, j);
			str.Format("%s (%s)", c->qid.toString(), c->nick.c_str());
			HTREEITEM hItem = tree.InsertItem(str, getApp()->getFaceIndex(c->face),
				getApp()->getFaceIndex(c->face, STATUS_AWAY), parent);

			qid = new QID(c->qid);
			tree.SetItemData(hItem, (DWORD) qid);

			qidList.remove(c->qid.toString());
		}

		if (i == n - 2)
			stranger = parent;
	}

	HTREEITEM item;

	// Add the remaining UINs to the stranger folder
	StrList::iterator it;
	for (it = qidList.begin(); it != qidList.end(); ++it) {
		const char *s = (*it).c_str();
		qid = new QID;
		if (!qid->parse(s)) {
			delete qid;
			continue;
		}

		item = tree.InsertItem(s, getApp()->getFaceIndex(0),
			getApp()->getFaceIndex(0, STATUS_AWAY), stranger);
		tree.SetItemData(item, (DWORD) qid);
	}

	str.LoadString(IDS_SYSMSG);
	image = getApp()->iconIndex(ICON_SYSMSG);
	item = tree.InsertItem(str, image, image, root);
	qid = new QID;
	tree.SetItemData(item, (DWORD) qid);
	
	return 0;
}
Esempio n. 30
0
// OpenPK3
// -------
// Opens a PK3 ( or zip ) file and creates a list of filenames
// and zip info structures
// 
boolean OpenPK3(const char *filename)
{
  char cFilename[WORK_LEN];
  char cName[WORK_LEN];
  char cWork[WORK_LEN];
  unz_file_info zInfo;
  unzFile *zFile = new unzFile(unzOpen(filename));
  g_zFiles.Add(zFile);
  if (zFile != NULL)
  {
    int nStatus = unzGoToFirstFile(*zFile);
    while (nStatus == UNZ_OK)
    {
      cFilename[0] = '\0';
      unzGetCurrentFileInfo(*zFile, &zInfo, cFilename, WORK_LEN, NULL, 0, NULL, 0);
      strlwr(cFilename);
    	__ConvertDOSToUnixName( cWork, cFilename);
      if (strstr(cWork, ".") != NULL)
      {
        PK3FileInfo *pInfo = new PK3FileInfo();
        pInfo->m_pName = __StrDup(cWork);
        memcpy(&pInfo->m_zInfo, (unz_s*)*zFile, sizeof(unz_s));
        pInfo->m_lSize = zInfo.uncompressed_size;
        pInfo->m_zFile = *zFile;
        g_PK3Files.Add(pInfo);
      }
      char *p = strstr(cFilename, TEXTURE_PATH);
      if (p != NULL)
      {
        // FIXME: path differences per os ?
        // catch solo directory entry
        if (strlen(p) > strlen(TEXTURE_PATH) + 1)
        {
          // skip textures + path seperator
          p += strlen(TEXTURE_PATH) + 1;
          int nEnd = strcspn(p, PATH_SEPERATORS);
          strncpy(cName, p, nEnd);
          cName[nEnd] = '\0';

          boolean bFound = false;
          StrList *pl = g_PK3TexturePaths.Next();
          while (pl != NULL)
          {
            if (strcmpi(pl->Ref(), cName) == 0)
            {
              // already have this, continue
              bFound = true;
              break;
            }
            pl = pl->Next();
          }
          if (!bFound)
          {
            g_PK3TexturePaths.Add(new Str(cName));
          }
        }
      }
      nStatus = unzGoToNextFile(*zFile);
    }
  }
  return (zFile != NULL);
}