Exemplo n.º 1
0
/* Returns dependent variable length for the given dependencies. */
static int citi_vector_length (strlist deps) {
  int n = 1;
  // no dependencies
  if (deps.length () <= 0)
    return 0;
  // calculate length of resulting dependent variable
  for (int i = 0; i < deps.length(); i++) {
    vector * v = citi_result->findDependency (deps.get (i));
    if (v != NULL) n *= v->getSize ();
  }
  return n;
}
Exemplo n.º 2
0
void CIniFileBase::GetKeyList ( LPCTSTR lpSectionName, strlist &List )
{
	List.clear();

	CGuard Guard(m_CS);
	if (!m_File.IsOpen())
	{
		return; 
	}

	if (lpSectionName == NULL || _tcslen(lpSectionName) == 0)
	{
		lpSectionName = "default";
	}

	if (MoveToSectionNameData(lpSectionName,true))
	{
		for (KeyValueList::iterator iter = m_CurrentSectionData.begin(); iter != m_CurrentSectionData.end(); iter++)
		{
			List.push_back(iter->first);
		}
	}
}
Exemplo n.º 3
0
// TODO: implement with boost::filesystem
bool PATHMANAGER::DirList(string dirpath, strlist& dirlist, string extension)
{
//------Folder listing code for POSIX
#ifndef _WIN32
	DIR *dp;
	struct dirent *ep;
	dp = opendir(dirpath.c_str());
	if (dp != NULL)
	{
		while (ep = readdir(dp))
		{
			//puts (ep->d_name);
			string newname = ep->d_name;
			if (newname[0] != '.')
			{
				dirlist.push_back(newname);
			}
		}
		(void) closedir(dp);
	}
	else
		return false;
#else
//------Folder listing for WIN32
	HANDLE          hList;
	TCHAR           szDir[MAX_PATH+1];
	WIN32_FIND_DATA FileData;

	// Get the proper directory path
	sprintf(szDir, "%s\\*", dirpath.c_str());

	// Get the first file
	hList = FindFirstFile(szDir, &FileData);
	if (hList == INVALID_HANDLE_VALUE)
	{ 
		//no files found.  that's OK
	}
	else
	{
		// Traverse through the directory structure
		while (FindNextFile(hList, &FileData))
		{
			// Check the object is a directory or not
			if (FileData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
			{} else
			{
				if (FileData.cFileName[0] != '.')
				{
					dirlist.push_back(FileData.cFileName);
				}
			}
		}
	}

	FindClose(hList);
#endif
//------End
	
	//remove non-matcthing extensions
	if (!extension.empty())
	{
		list <list <string>::iterator> todel;
		for (list <string>::iterator i = dirlist.begin(); i != dirlist.end(); ++i)
		{
			if (i->find(extension) != i->length()-extension.length())
				todel.push_back(i);
		}
		
		for (list <list <string>::iterator>::iterator i = todel.begin(); i != todel.end(); ++i)
			dirlist.erase(*i);
	}
	
	dirlist.sort();
	return true;
}