コード例 #1
0
		const std::vector<boost::filesystem::path>& ScanDirectory(const char *path,
			const char *pattern, int recurseDepth, std::vector < boost::filesystem::path >
			&fileVector/* = *(new vector<boost::filesystem::path>())*/)
		{
			boost::filesystem::path fullpath(path);
			std::vector<boost::filesystem::path> &ret = fileVector;

			if (!boost::filesystem::exists(fullpath))
			{
				return ret;
			}
			/// �޲ι��캯��������Ǹ�iterator��value ժ������
			/// If the end of the directory elements is reached, the iterator becomes equal 
			/// to the end iterator value. The constructor directory_iterator() with no arguments 
			/// always constructs an end iterator object, which is the only legitimate iterator to 
			/// be used for the end condition. The result of operator* on an end iterator is not defined. 
			/// For any other iterator value a const directory_entry& is returned. The result ofoperator-> 
			/// on an end iterator is not defined. For any other iterator value a const directory_entry* is returned.
			boost::filesystem::directory_iterator end_iter;
			for (boost::filesystem::directory_iterator iter(fullpath); iter != end_iter; ++iter)
			{
				try
				{
					if (boost::filesystem::is_directory(*iter))
					{
						if (recurseDepth > 0)
						{
							ScanDirectory(iter->path().string().c_str(), pattern, recurseDepth - 1, ret);
						}
						else if (recurseDepth == -1)
						{
							ScanDirectory(iter->path().string().c_str(), pattern, -1, ret);
						}
					}
					else
					{
						boost::regex reg(pattern);
						if (boost::regex_match(iter->path().filename().string(), reg))
						{
							ret.push_back(iter->path());
						}
					}
				}
				catch (const std::exception&)
				{
					continue;
				}
			}
			return ret;
		}
コード例 #2
0
ファイル: cmdlib.cpp プロジェクト: Marqt/ViZDoom
void ScanDirectory(TArray<FFileList> &list, const char *dirpath)
{
	DIR *directory = opendir(dirpath);
	if(directory == NULL)
		return;

	struct dirent *file;
	while((file = readdir(directory)) != NULL)
	{
		if(file->d_name[0] == '.') //File is hidden or ./.. directory so ignore it.
			continue;

		FFileList *fl = &list[list.Reserve(1)];
		fl->Filename << dirpath << file->d_name;

		struct stat fileStat;
		stat(fl->Filename, &fileStat);
		fl->isDirectory = S_ISDIR(fileStat.st_mode);

		if(fl->isDirectory)
		{
			FString newdir = fl->Filename;
			newdir += "/";
			ScanDirectory(list, newdir);
			continue;
		}
	}

	closedir(directory);
}
コード例 #3
0
ファイル: filesystem.hpp プロジェクト: Mogito89/TOX002
void ScanDirectory(const std::string& strPath, OutIter out, Predicate pred, FollowType follow)
{

	typedef boost::filesystem::directory_iterator iterator;

	if(!Exists(strPath)) return;

	boost::filesystem::path p(strPath);
	iterator end;
	iterator i;

	try { i = iterator(p); }
	catch(std::exception&) { return; }	
	
	for(; i != end; ++i)
	{
		if(boost::filesystem::is_symlink(i->path())) continue;

		const std::string s = i->string();
		if(pred(s))
			*out++ = s;
		if(follow == FOLLOW && boost::filesystem::is_directory(i->status()))
			ScanDirectory(s, out, pred, follow);
	}
}
コード例 #4
0
void
JVMGetSourceFileList::ScanDirectory
	(
	const JCharacter* path
	)
{
	JDirInfo* info;
	if (!JDirInfo::Create(path, &info))
		{
		return;
		}

	JXFileListTable* table = (GetFileList())->GetTable();

	const JSize count = info->GetEntryCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JDirEntry& e = info->GetEntry(i);
		if (e.GetType() == JDirEntry::kFile)
			{
			const CBTextFileType fileType =
				(CMGetPrefsManager())->GetFileType(e.GetName());
			if (fileType == kCBJavaSourceFT)
				{
				table->AddFile(e.GetFullName());
				}
			}
		else if (e.GetType() == JDirEntry::kDir)
			{
			ScanDirectory(e.GetFullName());
			}
		}

	delete info;
}
コード例 #5
0
void CExampleDemoDlg::OnBnClickedBtnOpen()
{


/*
	CFileDialog fileDialog(true, NULL, NULL, NULL, TEXT("所有支持的图片格式|*.jpg;*.jpeg;*.bmp;*.png|Jpeg图片(*.jpg;*.jpeg;)|*.jpg;*.jpeg|Windows位图(*.bmp)|*.bmp|PNG 格式(*.png)|*.png||"));	
	if (fileDialog.DoModal() != IDOK)
	{
		return;
	}
	CString strFoo =fileDialog.GetPathName();
	WCHAR wstr[256];
	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, strFoo.GetBuffer(0), -1, wstr, 256);

	Bitmap* pInImage = Bitmap::FromFile(wstr);
	if (pInImage->GetLastStatus() == -1)
	{
		SAFE_DELETE(pInImage);
		return;
	}
	SAFE_DELETE(m_pOrignImage);
	m_pOrignImage =  pInImage;

	this->Invalidate(true);*/

	char szPath[MAX_PATH];     //存放选择的目录路径 
	CString str;

	ZeroMemory(szPath, sizeof(szPath));

	BROWSEINFO bi;
	bi.hwndOwner = m_hWnd;
	bi.pidlRoot = NULL;

	bi.pszDisplayName = szPath;
	bi.lpszTitle = "请选择需要打包的目录:";
	bi.ulFlags = 0;
	bi.lpfn = NULL;
	bi.lParam = 0;
	bi.iImage = 0;
	//弹出选择目录对话框
	LPITEMIDLIST lp = SHBrowseForFolder(&bi);
	
	if (lp && SHGetPathFromIDList(lp, szPath))
	{
		m_imagefilepathname.clear();
		m_imagefilename.clear();
		ScanDirectory(szPath, ".jpg", m_imagefilename);//filesrc是文件夹名字
		for (int i=0;i<m_imagefilename.size();i++)
		{
			m_imagefilepathname.push_back(szPath + string("\\") + m_imagefilename[i]);
		}
		
		OnBnClickedBtnNext();

	}
	else
		AfxMessageBox("无效的目录,请重新选择");
}
コード例 #6
0
void
CBFileListTable::ScanDirectory
	(
	const JString&				origPath,
	const JBoolean				recurse,
	const JPtrArray<JString>&	allSuffixList,
	CBSymbolList*				symbolList,
	CBCTree*					cTree,
	CBJavaTree*					javaTree,
	JProgressDisplay&			pg
	)
{
	JString path;
	JDirInfo* info;
	if (!JGetTrueName(origPath, &path) ||
		!JDirInfo::Create(path, &info))
		{
		return;
		}

	const JSize count = info->GetEntryCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JDirEntry& entry = info->GetEntry(i);

		// If it's a directory, recurse.

		if (entry.IsDirectory() && recurse &&
			!entry.IsLink() && !JIsVCSDirectory(entry.GetName()))
			{
			ScanDirectory(entry.GetFullName(), recurse,
						  allSuffixList, symbolList,
						  cTree, javaTree,
						  pg);
			}

		// If it's a file ending in one of the suffixes, parse it.

		else if (entry.IsFile())
			{
			JString trueName = entry.GetFullName();
			time_t modTime   = entry.GetModTime();
			if (entry.IsWorkingLink())
				{
				const JBoolean ok = JGetTrueName(entry.GetFullName(), &trueName);
				assert( ok );
				const JError err = JGetModificationTime(trueName, &modTime);
				assert( err.OK() );
				}

			ParseFile(trueName, allSuffixList, modTime,
					  symbolList, cTree, javaTree);
			}

		pg.IncrementProgress();
		}

	delete info;
}
コード例 #7
0
ファイル: ResourceEditor.cpp プロジェクト: kichik/nsis-1
// This function scans a give resource directory and return a CResourceDirectory object
// rdRoot must point to the root directory of the resource section
CResourceDirectory* CResourceEditor::ScanDirectory(PRESOURCE_DIRECTORY rdRoot, PRESOURCE_DIRECTORY rdToScan) {
  // Create CResourceDirectory from rdToScan
  CResourceDirectory* rdc = new CResourceDirectory(PIMAGE_RESOURCE_DIRECTORY(rdToScan));
  char* szName;
  PIMAGE_RESOURCE_DATA_ENTRY rde;

  // Go through all entries of this resource directory
  for (int i = 0; i < rdToScan->Header.NumberOfNamedEntries + rdToScan->Header.NumberOfIdEntries; i++) {
    // If this entry points to data entry get a pointer to it
    if (!rdToScan->Entries[i].DataIsDirectory)
      rde = PIMAGE_RESOURCE_DATA_ENTRY(rdToScan->Entries[i].OffsetToData + (BYTE*)rdRoot);

    // If this entry has a name, translate it from Unicode
    if (rdToScan->Entries[i].NameIsString) {
      PIMAGE_RESOURCE_DIR_STRING_U rds = PIMAGE_RESOURCE_DIR_STRING_U(rdToScan->Entries[i].NameOffset + (char*)rdRoot);

      int mbsSize = WideCharToMultiByte(CP_ACP, 0, rds->NameString, rds->Length, 0, 0, 0, 0);
      szName = new char[mbsSize+1];
      WideCharToMultiByte(CP_ACP, 0, rds->NameString, rds->Length, szName, mbsSize, 0, 0);
      szName[mbsSize] = 0;
    }
    // Else, set the name to this entry's id
    else
      szName = MAKEINTRESOURCE(rdToScan->Entries[i].Id);

    if (rdToScan->Entries[i].DataIsDirectory)
      rdc->AddEntry(
        new CResourceDirectoryEntry(
          szName,
          ScanDirectory(
            rdRoot,
            PRESOURCE_DIRECTORY(rdToScan->Entries[i].OffsetToDirectory + (BYTE*)rdRoot)
          )
        )
      );
    else
      rdc->AddEntry(
        new CResourceDirectoryEntry(
          szName,
          new CResourceDataEntry(
            (BYTE*)rdRoot + rde->OffsetToData - m_dwResourceSectionVA,
            rde->Size,
            rde->CodePage
          )
        )
      );

    // Delete the dynamicly allocated name if it is a name and not an id
    if (!IS_INTRESOURCE(szName))
      delete [] szName;
  }

  return rdc;
}
コード例 #8
0
ファイル: vdr.c プロジェクト: chouquette/vlc
/*****************************************************************************
 * Open a directory
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    access_t *p_access = (access_t*)p_this;

    if( !p_access->psz_filepath )
        return VLC_EGENERIC;

    /* Some tests can be skipped if this module was explicitly requested.
     * That way, the user can play "corrupt" recordings if necessary
     * and we can avoid false positives in the general case. */
    bool b_strict = strcmp( p_access->psz_name, "vdr" );

    /* Do a quick test based on the directory name to see if this
     * directory might contain a VDR recording. We can be reasonably
     * sure if ScanDirectory() actually finds files. */
    if( b_strict )
    {
        char psz_extension[4];
        int i_length = 0;
        const char *psz_name = BaseName( p_access->psz_filepath );
        if( sscanf( psz_name, "%*u-%*u-%*u.%*u.%*u.%*u%*[-.]%*u.%3s%n",
            psz_extension, &i_length ) != 1 || strcasecmp( psz_extension, "rec" ) ||
            ( psz_name[i_length] != DIR_SEP_CHAR && psz_name[i_length] != '\0' ) )
            return VLC_EGENERIC;
    }

    /* Only directories can be recordings */
    struct stat st;
    if( vlc_stat( p_access->psz_filepath, &st ) ||
        !S_ISDIR( st.st_mode ) )
        return VLC_EGENERIC;

    access_sys_t *p_sys = vlc_calloc( p_this, 1, sizeof( *p_sys ) );

    if( unlikely(p_sys == NULL) )
        return VLC_ENOMEM;

    p_access->p_sys = p_sys;
    p_sys->fd = -1;
    p_sys->cur_seekpoint = 0;
    p_sys->fps = var_InheritFloat( p_access, "vdr-fps" );
    ARRAY_INIT( p_sys->file_sizes );

    /* Import all files and prepare playback. */
    if( !ScanDirectory( p_access ) ||
        !SwitchFile( p_access, 0 ) )
    {
        Close( p_this );
        return VLC_EGENERIC;
    }

    ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek );
    return VLC_SUCCESS;
}
コード例 #9
0
void SystemProcessPath::Pathstr(std::string str)
{	
	boost::filesystem::path rootPath( str );
  if( exists( rootPath ) )
  {
    if( is_directory( rootPath ) )
      ScanDirectory( rootPath );
    else
      outputFileInfo( rootPath );
  }  
}
コード例 #10
0
void SystemProcessPath::ScanDirectory( const boost::filesystem::path& rPath )
{
  std::vector<boost::filesystem::path> vList;
  copy( boost::filesystem::directory_iterator(rPath), boost::filesystem::directory_iterator(), back_inserter( vList ) );
  for( std::vector<boost::filesystem::path>::const_iterator it = vList.begin(); it != vList.end(); ++ it )
  {
    if( is_directory( *it ) )
      ScanDirectory( *it );
    else
      outputFileInfo( *it );
  }
}
コード例 #11
0
KVRunListCreator::KVRunListCreator(const TString& dir, const TString& datatype, const TString& fmt)
{
   // Give directory to scan, optional format for runfile names
   SetRunDir(dir);
   if (fmt != "") SetFileFormat(fmt);
   else SetFileFormat(gEnv->GetValue("DataSet.RunFileName.raw", "run_%04d.dat%*"));
   fRunInfos.SetOwner();
   fDataType = datatype;
   ScanDirectory();
   TFile f("runinfos.root", "recreate");
   GetRunInfos().Write();
   f.Close();
}
コード例 #12
0
ファイル: playlist.cpp プロジェクト: ARSekkat/gpac
void CPlaylist::HandleSelection()
{
	char szName[100];
	GetSelectionName(szName);

	/*sub-directory*/
	if ((szName[0] == '+') && (szName[1] == ' ')) {
		/*browse up*/
		if ((szName[2] == '.') && (szName[3] == '.')) {
			char *prev = strrchr(szCurrentDir, '\\');
			if (prev) {
				prev[0] = 0;
				ScanDirectory(szCurrentDir);
			} else {
				ScanDirectory(NULL);
			}
		} else {
			strcat(szCurrentDir, "\\");
			strcat(szCurrentDir, szName+2);
			ScanDirectory(szCurrentDir);
		}
	} else if (szName[1] == ':') {
		ScanDirectory(szName);
	} else {
		char szURL[1024];
		COsmo4AppUi *app = (COsmo4AppUi *) CEikonEnv::Static()->AppUi();
		if (playlist_mode) {
			TInt idx = iListBox->CurrentItemIndex();
#ifndef GPAC_GUI_ONLY
			const char *url = gf_cfg_get_key_name(m_user->config, "Playlist", idx);
			if (url) app->PlayURL(url);
#endif
		} else {
			gf_cfg_set_key(m_user->config, "General", "LastWorkingDir", (const char *) szCurrentDir);
			sprintf(szURL, "%s\\%s", szCurrentDir, szName);
			app->PlayURL(szURL);
		}
	}
}
コード例 #13
0
ファイル: cmdlib.cpp プロジェクト: Marqt/ViZDoom
void ScanDirectory(TArray<FFileList> &list, const char *dirpath)
{
	struct _finddata_t fileinfo;
	intptr_t handle;
	FString dirmatch;

	dirmatch << dirpath << "*";

	if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
	{
		I_Error("Could not scan '%s': %s\n", dirpath, strerror(errno));
	}
	else
	{
		do
		{
			if (fileinfo.attrib & _A_HIDDEN)
			{
				// Skip hidden files and directories. (Prevents SVN bookkeeping
				// info from being included.)
				continue;
			}

			if (fileinfo.attrib & _A_SUBDIR)
			{
				if (fileinfo.name[0] == '.' &&
					(fileinfo.name[1] == '\0' ||
					 (fileinfo.name[1] == '.' && fileinfo.name[2] == '\0')))
				{
					// Do not record . and .. directories.
					continue;
				}

				FFileList *fl = &list[list.Reserve(1)];
				fl->Filename << dirpath << fileinfo.name;
				fl->isDirectory = true;
				FString newdir = fl->Filename;
				newdir << "/";
				ScanDirectory(list, newdir);
			}
			else
			{
				FFileList *fl = &list[list.Reserve(1)];
				fl->Filename << dirpath << fileinfo.name;
				fl->isDirectory = false;
			}
		}
		while (_findnext(handle, &fileinfo) == 0);
		_findclose(handle);
	}
}
コード例 #14
0
ファイル: ResourceEditor.cpp プロジェクト: kichik/nsis-1
CResourceEditor::CResourceEditor(BYTE* pbPE, int iSize) {
  // Copy the data pointer
  m_pbPE = pbPE;
  m_iSize = iSize;

  // Get dos header
  m_dosHeader = (PIMAGE_DOS_HEADER)m_pbPE;
  if (m_dosHeader->e_magic != IMAGE_DOS_SIGNATURE)
    throw runtime_error("PE file contains invalid DOS header");

  // Get NT headers
  m_ntHeaders = (PIMAGE_NT_HEADERS)(m_pbPE + m_dosHeader->e_lfanew);
  if (m_ntHeaders->Signature != IMAGE_NT_SIGNATURE)
    throw runtime_error("PE file missing NT signature");

  // No check sum support yet...
  if (m_ntHeaders->OptionalHeader.CheckSum)
    throw runtime_error("CResourceEditor doesn't yet support check sum");

  // Get resource section virtual address
  m_dwResourceSectionVA = m_ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress;
  // Pointer to the sections headers array
  PIMAGE_SECTION_HEADER sectionHeadersArray = IMAGE_FIRST_SECTION(m_ntHeaders);

  m_dwResourceSectionIndex = -1;

  // Find resource section index in the array
  for (int i = 0; i < m_ntHeaders->FileHeader.NumberOfSections; i++) {
    if (m_dwResourceSectionVA == sectionHeadersArray[i].VirtualAddress) {
      // Remember resource section index
      m_dwResourceSectionIndex = i;
      // Check for invalid resource section pointer
      if (!sectionHeadersArray[i].PointerToRawData)
        throw runtime_error("Invalid resource section pointer");
    }

    // Invalid section pointer (goes beyond the PE image)
    if (sectionHeadersArray[i].PointerToRawData > (unsigned int)m_iSize)
      throw runtime_error("Invalid section pointer");
  }

  // No resource section...
  if (m_dwResourceSectionIndex == m_ntHeaders->FileHeader.NumberOfSections)
    throw runtime_error("PE file doesn't contain any resource section");

  // Pointer to section data, the first resource directory
  PRESOURCE_DIRECTORY rdRoot = PRESOURCE_DIRECTORY(m_pbPE + sectionHeadersArray[m_dwResourceSectionIndex].PointerToRawData);

  // Scan the resource directory
  m_cResDir = ScanDirectory(rdRoot, rdRoot);
}
コード例 #15
0
void
JVMGetSourceFileList::Starting()
{
	CMGetSourceFileList::Starting();

	dynamic_cast<JVMLink*>(CMGetLink())->FlushClassList();

	JXFileListTable* table = (GetFileList())->GetTable();
	table->RemoveAllFiles();

	const JPtrArray<JString>& list = dynamic_cast<JVMLink*>(CMGetLink())->GetSourcePathList();
	const JSize count              = list.GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		ScanDirectory(*(list.NthElement(i)));
		}
}
コード例 #16
0
LuaParser::LuaParser(QDir Directory, QListView *LoadFuncView, QListView *FileListView, QListView* AppearencesListView, QListView* AppearencePropFuncListView)
{
    this->LoadFuncView = LoadFuncView;
    this->FileListView = FileListView;
    this->AppearencesListView = AppearencesListView;
    this->AppearencePropFuncListView = AppearencePropFuncListView;
    this->Directory = Directory;

    FuncListMdl = NULL;
    AppsListMdl = NULL;
    AppsFuncPropListMdl = NULL;
    FileListMdl = NULL;

    FuncProxyModel = NULL;
    AppProxyModel = NULL;

    LuaFiles = new QStringList();
    ScanDirectory();
}
コード例 #17
0
unsigned long ContentManager::Process(void* parameter) {

	// Set our thread name and begin processing
	SetThreadName("ContentManager");

	bIsScanning = FALSE;
	// Loop forever
	for(;;)	{

		// Make sure we are not paused
		if(paused) {
			bIsScanning = FALSE;
			Sleep(500);
			continue;
		}

		// Get a item from our queue
		if(scanPathQueue.size() == 0) {
			bIsScanning = FALSE;
			Sleep(500);
			continue;
		}

		bIsScanning = TRUE;
		// Get our item and remove it from the queue
		SCAN_LOCK;
		ScanPath scanPath = scanPathQueue.at(0);
		scanPathQueue.erase(scanPathQueue.begin());
		SCAN_UNLOCK;

		// Now lets scan this directory
		ScanDirectory(&scanPath, scanPath.Path, scanPath.ScanDepth);
		szStatusMsg = L"";

		// Take a little break
		Sleep(500);
	}

	bIsScanning = FALSE;
	// All done
	return 0;
}
コード例 #18
0
ファイル: find_x.c プロジェクト: 976717326/imu_autopilot
/*!\brief Find next directory entry (file or directory)
 * \return 		0 if nothing found, 1 if something found
 * 
 * Check ffblk.f_attr if you have a file or a dir entry.
 * Always starts to search from beginning of a directory.
 * NEVER call this before calling Findfirst() !
 * Your program crashes and your hardware will be destroyed.
 * 
 * Findfirst(), Findnext(), Findnext()....
 *
 * If you change to another directory you have to call Findfirst() first again !
 */
unsigned char Findnext(void)
//###########################################################
{
 U8 i;

 //delete last data
 for(i=0; i<13; i++) ffblk.ff_name[i]=0; //clean last filename

#ifdef USE_FINDLONG
 for(i=0; i<_MAX_NAME; i++) ffblk.ff_longname[i]=0;	// clean the long filename.
#endif

 ffblk.ff_fsize=0; 	      		//no filesize
 ffblk.ff_attr=ATTR_NO_ATTR; 	      	//no file attr
 ffblk.newposition=0;  	//no position for next search

 if(ScanDirectory(-1, FirstDirCluster) == FULL_MATCH) return 1;

 return 0;
}
コード例 #19
0
void CPlaylist::RefreshPlaylist()
{
	if (playlist_mode) {
		u32 count = gf_cfg_get_key_count(m_user->config, "Playlist");
		ResetView();
		for (u32 i=0; i<count; i++) {
			const char *opt = gf_cfg_get_key_name(m_user->config, "Playlist", i);
			const char *sep = strrchr(opt, '\\');
			if (!sep) sep = strrchr(opt, '/');
			AddItem(sep ? (sep+1) : opt, 0);
		}
		if (!count) AddItem("[empty]", 0);

		FlushItemList();

		((COsmo4AppUi *) CEikonEnv::Static()->AppUi())->SetTitle("Playlist", 0);
	} else {
		ScanDirectory(szCurrentDir);
	}
}
コード例 #20
0
		static void ScanDirectory(const std::string& path, std::function<void(const std::string& path, const char* filename)> callback,
				const std::string& requiredSuffix = "", bool recursive = true) {
			tinydir_dir dir;

			for (tinydir_open(&dir, path.c_str()); dir.has_next; tinydir_next(&dir)) {
				tinydir_file file;
				tinydir_readfile(&dir, &file);

				if (file.name[0] == '.')
					continue;

				if (file.is_dir) {
					if (recursive)
						ScanDirectory(path + "/" + file.name, callback, requiredSuffix, recursive);
				}
				else if (requiredSuffix.empty() || EndsWith(file.name, requiredSuffix))
					callback(path + "/" + file.name, file.name);
			}

			tinydir_close(&dir);
		}
コード例 #21
0
vector<Bitmap*> CExampleDemoDlg::LoadTemplateImg(string filesrc)
{
	vector<Bitmap*> tempplate;
	vector<string>filepathname;
	ScanDirectory(filesrc, ".jpg", filepathname);//filesrc是文件夹名字
	//std::sort(filepathname.begin(),filepathname.end());
	for (int i = 0; i < filepathname.size(); i++)
	{
		string image = filesrc+"\\"+ filepathname[i];
		std::wstring widestr = std::wstring(image.begin(), image.end());
		Bitmap* pInImage = Bitmap::FromFile(widestr.c_str());
		if (pInImage->GetLastStatus() == -1)
		{
			SAFE_DELETE(pInImage);
			continue;
		}

		Bitmap*  img = pInImage->Clone(0, 0, pInImage->GetWidth(), pInImage->GetHeight(), PixelFormat32bppARGB);
		tempplate.push_back(img);
	}
	return tempplate;
}
コード例 #22
0
ファイル: StateDownload.cpp プロジェクト: BwRy/core-symbian
//TFindFile and CFileMan classes support the use of wildcard characters. 
//An asterisk indicates any number of characters, and a question mark indicates a single character. 
//Note that in the context of these classes, * and *.* are equivalent and match to all files, 
//with and without extensions. Filename matching is case insensitive.
void CStateDownload::StartScanL(RFs& aFs,const TDesC& aSearchString, CDesCArray* aFileArray)
	{
	//retrieve all drives in mobile
	_LIT(KFormat,"%c:\\");
	TDriveList driveList;
	TInt err = aFs.DriveList(driveList);
	if(err != KErrNone)
		return;
	for(TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
		{
		if (driveList[driveNumber]) /** now we iterate through all the available drives */
			{
			TChar driveLetter;
			err = aFs.DriveToChar(driveNumber,driveLetter);
			TBuf<8> buf;
			buf.Format(KFormat,(TUint)driveLetter);
	
			CDirScan* dirScan = CDirScan::NewLC(aFs);
			dirScan->SetScanDataL(buf, KEntryAttDir|KEntryAttMatchExclusive, ESortNone, CDirScan::EScanDownTree);
			while(1)
				{
				CDir* dir = NULL;
				TRAPD(err, dirScan->NextL(dir));
				if(err == KErrPermissionDenied)  //we could'nt have the required capab
					{
					delete dir;
					continue;
					}
				if (dir == NULL) //there are no more directory to iterate
					{
					break;
					}
				delete dir;
				ScanDirectory(aFs, dirScan->FullPath(), aSearchString, aFileArray);
				}
			CleanupStack::PopAndDestroy(dirScan);
			}
		}
	}
コード例 #23
0
void
CBFileListTable::ScanAll
	(
	CBProjectTree*		fileTree,
	const CBDirList&	dirList,
	CBSymbolList*		symbolList,
	CBCTree*			cTree,
	CBJavaTree*			javaTree,
	JProgressDisplay&	pg
	)
{
	const JSize dirCount = dirList.GetElementCount();
	if (dirCount > 0 || (fileTree->GetProjectRoot())->HasChildren())
		{
		pg.VariableLengthProcessBeginning(JGetString(kParsingFilesID), kJFalse, kJTrue);

		JPtrArray<JString> allSuffixList(JPtrArrayT::kDeleteAll);
		(CBGetPrefsManager())->GetAllFileSuffixes(&allSuffixList);

		JString fullPath;
		JBoolean recurse;
		for (JIndex i=1; i<=dirCount; i++)
			{
			if (dirList.GetFullPath(i, &fullPath, &recurse))
				{
				ScanDirectory(fullPath, recurse,
							  allSuffixList, symbolList,
							  cTree, javaTree,
							  pg);
				}
			}

		fileTree->ParseFiles(this, allSuffixList, symbolList, cTree, javaTree, pg);

		pg.ProcessFinished();
		}
}
コード例 #24
0
void ContentManager::ScanDirectory(ScanPath* ScanPath, string Directory, int Levels) {
    
	// Check to make sure the default path doesnt already exist in the database
	string defaultFilePath = Directory + "default.xex";
	string defaultPath = defaultFilePath.substr(defaultFilePath.find_first_of(":") + 1);
	DebugMsg("ContentManager", "File Path : %s", defaultFilePath.c_str());
	if(FSDSql::getInstance().ItemPathExistsInDB(defaultPath, ScanPath)) {
		return;
	}

	// Check to make sure the default path doesnt already exist in the database
	defaultFilePath = Directory + "default.xbe";
	defaultPath = defaultFilePath.substr(defaultFilePath.find_first_of(":") + 1);
	DebugMsg("ContentManager", "File Path : %s", defaultFilePath.c_str());
	if(FSDSql::getInstance().ItemPathExistsInDB(defaultPath, ScanPath)) {
		return;
	}


	if(Levels == ScanPath->ScanDepth - 1)
		szStatusMsg = strtowstr(Directory);

	// Try and create default.xex
	ContentItemNew* item = ContentItemNew::CreateItem(ScanPath, Directory, "default.xex");
	if(item != NULL) {
		
		// We found a valid item so no need to continue
		AddItem(item);
		return;
	}

	// Try and create default.xbe
	item = ContentItemNew::CreateItem(ScanPath, Directory, "default.xbe");
	if(item != NULL) {
		
		// We found a valid item so no need to continue
		AddItem(item);
		return;
	}

	// Start finding our files
	string strFind = Directory + "*";
    WIN32_FIND_DATA wfd; HANDLE hFind;
    hFind = FindFirstFile( strFind.c_str(), &wfd );
    if(hFind == INVALID_HANDLE_VALUE) return;

	// Loop and find each
	do {

		// Lets check if this is a directory (and make sure its not our default!)
		if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
			
			string nextDirectory = Directory + wfd.cFileName + "\\";
			if(Levels == -1)
				ScanDirectory(ScanPath, nextDirectory, -1);
			else if(Levels > 0)
				ScanDirectory(ScanPath, nextDirectory, Levels - 1);

			continue;
		}

		// Make sure its not in our db
		string filePath = Directory + wfd.cFileName;
		string filePathShort = filePath.substr(filePath.find_first_of(":") + 1);
		if(FSDSql::getInstance().ItemPathExistsInDB(filePathShort, ScanPath))
			continue;
		
		// Try and create our item
		ContentItemNew* item = ContentItemNew::CreateItem(ScanPath, 
			Directory, wfd.cFileName);
		if(item != NULL)
			AddItem(item);

	}while(FindNextFile(hFind, &wfd));

	// Done finding
	FindClose( hFind );
}
コード例 #25
0
ファイル: LibUpdate.cpp プロジェクト: anonbeat/guayadeque
// -------------------------------------------------------------------------------- //
int guLibUpdateThread::ScanDirectory( wxString dirname, bool includedir )
{
  wxDir         Dir;
  wxString      FileName;
  wxString      LowerFileName;
  bool          FoundCover = false;
  wxString      FirstAudioFile;

  if( !dirname.EndsWith( wxT( "/" ) ) )
    dirname += wxT( "/" );

  //guLogMessage( wxT( "Scanning dir (%i) '%s'" ), includedir, dirname.c_str() );
  Dir.Open( dirname );

  if( !TestDestroy() && Dir.IsOpened() )
  {
    if( Dir.GetFirst( &FileName, wxEmptyString, wxDIR_FILES | wxDIR_DIRS ) )
    {
      do {
        if( FileName[ 0 ] == '.' )
          continue;

        if ( !m_ScanSymlinks && IsFileSymbolicLink( dirname + FileName ) )
            continue;

        int FileDate = GetFileLastChangeTime( dirname + FileName );
        if( Dir.Exists( dirname + FileName ) )
        {
          //guLogMessage( wxT( "Scanning dir '%s' : FileDate: %u  -> %u\n%u Tracks found" ), ( dirname + FileName ).c_str(), m_LastUpdate, FileDate, m_TrackFiles.Count() );
          ScanDirectory( dirname + FileName, includedir || ( FileDate > m_LastUpdate ) );

          wxCommandEvent event( wxEVT_MENU, ID_STATUSBAR_GAUGE_SETMAX );
          event.SetInt( m_GaugeId );
          event.SetExtraLong( m_TrackFiles.Count() );
          wxPostEvent( m_MainFrame, event );
        }
        else
        {
          //guLogMessage( wxT( "%s (%i): FileDate: %u  -> %u" ), ( dirname + FileName ).c_str(), includedir, m_LastUpdate, FileDate );
          if( includedir || ( FileDate > m_LastUpdate ) )
          {
            LowerFileName = FileName.Lower();

            if( guIsValidAudioFile( LowerFileName ) )
            {
              if( !m_Db->FindDeletedFile( dirname + FileName, false ) )
              {
                m_TrackFiles.Add( dirname + FileName );
                if( m_ScanEmbeddedCovers && FirstAudioFile.IsEmpty() )
                    FirstAudioFile = dirname + FileName;
              }
            }
            else if( guIsValidImageFile( LowerFileName ) )
            {
              if( SearchCoverWords( LowerFileName, m_CoverSearchWords ) )
              {
                //guLogMessage( wxT( "Adding image '%s'" ), wxString( dirname + FileName ).c_str() );
                m_ImageFiles.Add( dirname + FileName );
                FoundCover = true;
              }
            }
            else if( m_ScanAddPlayLists && guPlaylistFile::IsValidPlayList( LowerFileName ) )
            {
              m_PlayListFiles.Add( dirname + FileName );
            }
            else if( guCuePlaylistFile::IsValidFile( LowerFileName ) )
            {
              //
              m_CueFiles.Add( dirname + FileName );
            }
            //else
            //{
            //    guLogMessage( wxT( "Unknown file: '%s'"), ( dirname + FileName ).c_str() );
            //}
          }
        }
      } while( !TestDestroy() && Dir.GetNext( &FileName ) );

      if( m_ScanEmbeddedCovers && !FoundCover && !FirstAudioFile.IsEmpty() )
      {
        m_ImageFiles.Add( FirstAudioFile );
      }
    }
  }
  else
  {
      guLogMessage( wxT( "Could not open the dir '%s'" ), dirname.c_str() );
  }
  return 1;
}
コード例 #26
0
ファイル: slimhelper.cpp プロジェクト: dreamsxin/PcManager
BOOL slimhelper::ScanDirectory(const CString& strDirectory,
                               ISystemSlimCallBack* piCallback)
{
    BOOL retval = FALSE;
    CString strPath;
    CString strFind;
    HANDLE hFind = INVALID_HANDLE_VALUE;
    WIN32_FIND_DATA findData;
    BOOL bRetCode;
    BOOL bContinue;

    if (strDirectory.IsEmpty() || !piCallback)
        goto clean0;

    strPath = strDirectory;
    if (strPath[strPath.GetLength() - 1] != _T('\\'))
        strPath += _T("\\");

    strFind = strPath + _T("*.*");

    hFind = ::FindFirstFile(strFind, &findData); 
    if (INVALID_HANDLE_VALUE == hFind)
    {
        retval = TRUE;
        goto clean0;
    }

    bRetCode = TRUE;
    while (bRetCode)
    {
        if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  
        {
            if (_tcscmp(findData.cFileName, _T(".")) &&
                _tcscmp(findData.cFileName, _T("..")))
            {
                CString strSubDir = strPath + findData.cFileName;
                strSubDir += _T("\\");
                if (!ScanDirectory(strSubDir, piCallback))
                    goto clean0;
            }
        }
        else
        {
            CString strFullFilePath = strPath + findData.cFileName;
            ULONGLONG qwFileSize = ((ULONGLONG)findData.nFileSizeHigh << 32) + findData.nFileSizeLow;
            
            if (KGetWinVersion() <= WINVERSION_SERVER_2003)
            {
                if (!::SfcIsFileProtected(NULL, strFullFilePath))
                    ScanFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }
            else
            {
                ScanFile(strFullFilePath, qwFileSize, findData.dwFileAttributes, piCallback);
            }

            bContinue = piCallback->OnIdle();
            if (!bContinue)
                goto clean0;
        }

        bRetCode = ::FindNextFile(hFind, &findData);
    }

    retval = TRUE;

clean0:
    if (hFind != INVALID_HANDLE_VALUE)
    {
        FindClose(hFind);
        hFind = INVALID_HANDLE_VALUE;
    }

    return retval;
}
コード例 #27
0
static int
Scanner(ConstUnicode lockDir,    // IN:
        int (*func)(             // IN:
               ConstUnicode lockDir,
               ConstUnicode fileName,
               LockValues *memberValues,
               LockValues *myValues
            ),
        LockValues *myValues,    // IN:
        Bool cleanUp)            // IN:
{
   int        err;
   ActiveLock *ptr;

   ASSERT(lockDir);

   myValues->lockList = NULL;

   while (TRUE) {
      ActiveLock *prev;

      err = ScanDirectory(lockDir, func, myValues, cleanUp);
      if ((err > 0) || ((err == 0) && (myValues->lockList == NULL))) {
         break;
      }

      prev = NULL;
      ptr = myValues->lockList;

      /*
       * Some 'D' entries have persisted. Age them and remove those that
       * have not progressed. Remove those that have disappeared.
       */

      while (ptr != NULL) {
         Bool remove;

         if (ptr->marked) {
            if (ptr->age > FILELOCK_PROGRESS_DEARTH) {
               Unicode temp;
               Unicode path;
               UnicodeIndex index;

               ASSERT(Unicode_StartsWith(ptr->dirName, "D"));

               Log(LGPFX" %s discarding %s data from '%s'.\n",
                   __FUNCTION__, UTF8(ptr->dirName), UTF8(lockDir));

               path = Unicode_Join(lockDir, DIRSEPS, ptr->dirName, NULL);

               index = Unicode_FindLast(path, "D");
               ASSERT(index != UNICODE_INDEX_NOT_FOUND);

               temp = Unicode_Replace(path, index, 1, "M");
               FileDeletionRobust(temp, FALSE);
               Unicode_Free(temp);

               temp = Unicode_Replace(path, index, 1, "E");
               FileDeletionRobust(temp, FALSE);
               Unicode_Free(temp);

               FileRemoveDirectoryRobust(path);

               Unicode_Free(path);

               remove = TRUE;
            } else {
               ptr->marked = FALSE;
               ptr->age += FILELOCK_PROGRESS_SAMPLE;

               remove = FALSE;
            }
         } else {
            remove = TRUE;
         }

         if (remove) {
            if (prev == NULL) {
               myValues->lockList = ptr->next;
            } else {
               prev->next = ptr->next;
            }
         }

         prev = ptr;
         ptr = ptr->next;
      }

      FileSleeper(FILELOCK_PROGRESS_SAMPLE); // relax
   }

   /* Clean up anything still on the list; they are no longer important */
   while (myValues->lockList != NULL) {
      ptr = myValues->lockList;
      myValues->lockList = ptr->next;

      Unicode_Free(ptr->dirName);

      free(ptr);
   }

   return err;
}
コード例 #28
0
ファイル: filesystem.hpp プロジェクト: Mogito89/TOX002
void ScanDirectory(const std::string& strPath, OutIter out, ElementType mask, FollowType follow)
{
	ScanDirectory(strPath, out, TypeChecker(mask), follow);
}
コード例 #29
0
ファイル: klr.core45.cpp プロジェクト: UIKit0/KRuntime
extern "C" __declspec(dllexport) bool __stdcall CallApplicationMain(PCALL_APPLICATION_MAIN_DATA data)
{
    HRESULT hr = S_OK;
    errno_t errno = 0;
    FnGetCLRRuntimeHost pfnGetCLRRuntimeHost = nullptr;
    ICLRRuntimeHost2* pCLRRuntimeHost = nullptr;
    TCHAR szCurrentDirectory[MAX_PATH];
    TCHAR szCoreClrDirectory[MAX_PATH];
    TCHAR lpCoreClrModulePath[MAX_PATH];
    size_t cchTrustedPlatformAssemblies = 0;
    LPWSTR pwszTrustedPlatformAssemblies = nullptr;

    if (data->klrDirectory) {
        errno = wcscpy_s(szCurrentDirectory, data->klrDirectory);
        CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);
    }
    else {
        GetModuleDirectory(NULL, szCurrentDirectory);
    }

    HMODULE hCoreCLRModule = LoadCoreClr();
    if (!hCoreCLRModule)
    {
        printf_s("Failed to locate coreclr.dll.\n");
        return false;
    }

    // Get the path to the module
    DWORD dwCoreClrModulePathSize = GetModuleFileName(hCoreCLRModule, lpCoreClrModulePath, MAX_PATH);
    lpCoreClrModulePath[dwCoreClrModulePathSize] = '\0';

    GetModuleDirectory(hCoreCLRModule, szCoreClrDirectory);

    HMODULE ignoreModule;
    // Pin the module - CoreCLR.dll does not support being unloaded.
    if (!::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN, lpCoreClrModulePath, &ignoreModule))
    {
        printf_s("Failed to pin coreclr.dll.\n");
        return false;
    }

    pfnGetCLRRuntimeHost = (FnGetCLRRuntimeHost)::GetProcAddress(hCoreCLRModule, "GetCLRRuntimeHost");
    if (!pfnGetCLRRuntimeHost)
    {
        printf_s("Failed to find export GetCLRRuntimeHost.\n");
        return false;
    }

    hr = pfnGetCLRRuntimeHost(IID_ICLRRuntimeHost2, (IUnknown**)&pCLRRuntimeHost);
    if (FAILED(hr))
    {
        printf_s("Failed to get IID_ICLRRuntimeHost2.\n");
        return false;
    }

    STARTUP_FLAGS dwStartupFlags = (STARTUP_FLAGS)(
        STARTUP_FLAGS::STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN |
        STARTUP_FLAGS::STARTUP_SINGLE_APPDOMAIN |
        STARTUP_FLAGS::STARTUP_SERVER_GC
        );

    pCLRRuntimeHost->SetStartupFlags(dwStartupFlags);

    // Authenticate with either CORECLR_HOST_AUTHENTICATION_KEY or CORECLR_HOST_AUTHENTICATION_KEY_NONGEN 
    hr = pCLRRuntimeHost->Authenticate(CORECLR_HOST_AUTHENTICATION_KEY);
    if (FAILED(hr))
    {
        printf_s("Failed to Authenticate().\n");
        return false;
    }

    hr = pCLRRuntimeHost->Start();

    if (FAILED(hr))
    {
        printf_s("Failed to Start().\n");
        return false;
    }

    const wchar_t* property_keys[] =
    {
        // Allowed property names:
        // APPBASE
        // - The base path of the application from which the exe and other assemblies will be loaded
        L"APPBASE",
        //
        // TRUSTED_PLATFORM_ASSEMBLIES
        // - The list of complete paths to each of the fully trusted assemblies
        L"TRUSTED_PLATFORM_ASSEMBLIES",
        //
        // APP_PATHS
        // - The list of paths which will be probed by the assembly loader
        L"APP_PATHS",
        //
        // APP_NI_PATHS
        // - The list of additional paths that the assembly loader will probe for ngen images
        //
        // NATIVE_DLL_SEARCH_DIRECTORIES
        // - The list of paths that will be probed for native DLLs called by PInvoke
        //
    };

    cchTrustedPlatformAssemblies = TRUSTED_PLATFORM_ASSEMBLIES_STRING_BUFFER_SIZE_CCH;
    pwszTrustedPlatformAssemblies = (LPWSTR)calloc(cchTrustedPlatformAssemblies+1, sizeof(WCHAR));
    if (pwszTrustedPlatformAssemblies == NULL)
    {
        goto Finished;
    }
    pwszTrustedPlatformAssemblies[0] = L'\0';
    
    // Try native images first
    if (!ScanDirectory(szCoreClrDirectory, L"*.ni.dll", pwszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies))
    {
        if (!ScanDirectory(szCoreClrDirectory, L"*.dll", pwszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies))
        {
            printf_s("Failed to find files in the coreclr directory\n");
            return false;
        }
    }

    // Add the assembly containing the app domain manager to the trusted list

    errno = wcscat_s(pwszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies, szCurrentDirectory);
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    errno = wcscat_s(pwszTrustedPlatformAssemblies, cchTrustedPlatformAssemblies, L"klr.core45.managed.dll");
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    //wstring appPaths(szCurrentDirectory);
    WCHAR wszAppPaths[MAX_PATH];
    wszAppPaths[0] = L'\0';

    errno = wcscat_s(wszAppPaths, _countof(wszAppPaths), szCurrentDirectory);
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    errno = wcscat_s(wszAppPaths, _countof(wszAppPaths), L";");
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    errno = wcscat_s(wszAppPaths, _countof(wszAppPaths), szCoreClrDirectory);
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    errno = wcscat_s(wszAppPaths, _countof(wszAppPaths), L";");
    CHECK_RETURN_VALUE_FAIL_EXIT_VIA_FINISHED(errno);

    const wchar_t* property_values[] = {
        // APPBASE
        data->applicationBase,
        // TRUSTED_PLATFORM_ASSEMBLIES
        pwszTrustedPlatformAssemblies,
        // APP_PATHS
        wszAppPaths,
    };

    DWORD domainId;
    DWORD dwFlagsAppDomain =
        APPDOMAIN_ENABLE_PLATFORM_SPECIFIC_APPS |
        APPDOMAIN_ENABLE_PINVOKE_AND_CLASSIC_COMINTEROP;

    LPCWSTR szAssemblyName = L"klr.core45.managed, Version=0.1.0.0";
    LPCWSTR szEntryPointTypeName = L"DomainManager";
    LPCWSTR szMainMethodName = L"Execute";

    int nprops = sizeof(property_keys) / sizeof(wchar_t*);

    hr = pCLRRuntimeHost->CreateAppDomainWithManager(
        L"klr.core45.managed",
        dwFlagsAppDomain,
        NULL,
        NULL,
        nprops,
        property_keys,
        property_values,
        &domainId);

    if (FAILED(hr))
    {
        wprintf_s(L"TPA      %d %s\n", wcslen(pwszTrustedPlatformAssemblies), pwszTrustedPlatformAssemblies);
        wprintf_s(L"AppPaths %s\n", wszAppPaths);
        printf_s("Failed to create app domain (%d).\n", hr);
        return false;
    }

    HostMain pHostMain;

    hr = pCLRRuntimeHost->CreateDelegate(
        domainId,
        szAssemblyName,
        szEntryPointTypeName,
        szMainMethodName,
        (INT_PTR*)&pHostMain);

    if (FAILED(hr))
    {
        printf_s("Failed to create main delegate (%d).\n", hr);
        return false;
    }

    // REVIEW: Versioning? k 1.0, 2.0?
    SetEnvironmentVariable(L"TARGET_FRAMEWORK", L"k10");

    // Call main
    data->exitcode = pHostMain(data->argc, data->argv);

    pCLRRuntimeHost->UnloadAppDomain(domainId, true);

    pCLRRuntimeHost->Stop();
    
Finished:    
    if (pwszTrustedPlatformAssemblies != NULL)
    {
        free(pwszTrustedPlatformAssemblies);
        pwszTrustedPlatformAssemblies = NULL;
    }

    if (FAILED(hr))
    {
        return false;
    }
    else
    {
        return true;
    }
}
コード例 #30
0
void ScanGrub2::ScanConfigFile (char *dir, char *file_name)
{
    bool scan_kernel_setup = false;
    bool added_to_menu = false;
    bool found = false;
    bool variables = false;
    FILE *pf;
    //int default_boot_number = 0;

    pf = fopen (file_name, "r");
    if (!pf) {
	Log ("Couldn't open '%s'/'%s'", dir, file_name);
	ScanDirectory (dir);
	return;
    } else {
	Log ("Parsing '%s'/'%s'", dir, file_name);
    }

    MenuEntry menuEntry;

    menuEntry.Reset();
    menuEntry.check_default_boot = true;

    while (fgets (cfg_line, sizeof (cfg_line), pf)) {
	RemoveUnneededChars (cfg_line, '#');
	TabToSpace (cfg_line);
	StripChar (cfg_line, '{'); // dirty hack, use menuentry as start
        if (!variables && FindChar (cfg_line, '$')) {
		variables = true;
	}

	/*
	if ((strncasecmp (cfg_line, "set default", 11) == 0) && !FindChar (cfg_line, '$')) {
		GetValue(cfg_line);
		default_boot_number = atoi (cfg_line);
		continue;
	}
	*/

	if (strncasecmp (cfg_line, "menuentry ", 10) == 0) {
	    if (variables) {
	        Log ("Warning: Grub2 added menu entry '%s' with variable/s, they were removed.", cfg_line);
		variables = false;
	    }

	    // when a new label has been found then add the previous collected data to the menu
	    if (!added_to_menu && found) {
		menu->AddEntry (menuEntry);
		menuEntry.Reset();

		added_to_menu = true;
		found = false;
	    }
	    
	    StripChar (cfg_line, '"');
	    menuEntry.SetMenuLabel (cfg_line + 10);

	    scan_kernel_setup = true;
	}


	if (scan_kernel_setup) {
            //if (FindChar (cfg_line, '$'))
	    //    Log ("Grub2: Adding initrd/kernel args with variable '%s'", cfg_line);

    	    if (strncasecmp (cfg_line, "linux ", 6) == 0) {
		menuEntry.SetKernel (cfg_line + 6, dir);
		found = true;
		added_to_menu = false;
		
		char append[1024];
		strncpy (append, cfg_line + 6, sizeof (append));
		int start = Trim (append);
		int pos = FindChar (append + start, ' ');
		if (pos > -1) {
		    menuEntry.SetAppend (append + start + pos);
		}
	    } else if (strncasecmp (cfg_line, "initrd ", 7) == 0) {
		menuEntry.SetInitrd (cfg_line, dir);
	    }
	}
    }

    if (!added_to_menu && found) {
	menu->AddEntry (menuEntry);
    }

    fclose (pf);
}