예제 #1
0
boost::any LuaGraphTreeModel::getChild(const boost::any& parent, const UInt32& index) const
{
    try
    {
        BoostPath ThePath = boost::any_cast<BoostPath>(parent);

        if(!ThePath.empty() &&
           boost::filesystem::exists(ThePath))
        {
            boost::filesystem::directory_iterator end_iter;
            UInt32 Count(0);
            for ( boost::filesystem::directory_iterator dir_itr(ThePath); dir_itr != end_iter; ++dir_itr )
            {
                if( isValidFile(dir_itr->path()) )
                {
                    if(Count == index)
                    {
                        return boost::any(dir_itr->path());
                    }
                    ++Count;
                }
            }
        }
        return boost::any();
    }
    catch(boost::bad_any_cast &)
    {
        return boost::any();
    }
}
예제 #2
0
int FindFiles::openFolder(bool includeSubFolders, bool skipSystemFolders)
{
	char searchPattern[MAX_PATH];
	strcpy(searchPattern, m_currentFolder);
	strcat(searchPattern, "*");
	SetLastError(0);
	m_h = FindFirstFileA(searchPattern, &fd);
	int e = GetLastError();
	if (e != ERROR_SUCCESS)
	{
		FindClose(m_h);
		m_insearch = false;
		return e;
	}

	bool keep_looking = true;
	do
	{
        if (isValidFolder(skipSystemFolders))
		{
            if (includeSubFolders) storeFolder();
			keep_looking = false;
		}
		else if (isValidFile())
		{
			keep_looking = false;
		}
		else
		{
			FindNextFileA(m_h, &fd);
			e = GetLastError();
		}
	} while (keep_looking && e == ERROR_SUCCESS);
	return e;
} //int FindFiles::openFolder(WIN32_FIND_DATAA& fd, bool recursive)
예제 #3
0
파일: main.c 프로젝트: FH-Thomas-Herzog/C
/**
 * The main entry point to this program
 *
 * @param
 * 		int argc: the argument count
 * @param
 * 		char** argv: the arguments for this program
 */
int main(int argc, char** argv) {
	char* functionName;
	char* directory;

	/* check for function argument */
	if (argc < 3) {
		printf(
				"At least the root directory and function must be given !!! E.g.: ./app.bin ./ -grep NULL");
		exit(EXIT_FAILURE);
	} /* if */

	/* Validate directory */
	if (!isValidFile((directory = argv[1]))) {
		printf("Given directory does not exist !!! dir='%s'", argv[1]);
		exit(EXIT_FAILURE);
	} /* if */

	/* Validate given function name */
	functionName = argv[2] + 1;
	if (strcmp(functionName, PRINT_FILE_PROPS) == 0) {
		traverse(directory, &print, 0, NULL);
	} else if (strcmp(functionName, SEARCH_FILE) == 0) {
		if (argc < 4) {
			printf("Missing search pattern !!!");
			exit(EXIT_FAILURE);
		} /* if */
		traverse(directory, &grep, 1, argv[3]);
	} else {
		printf("Function not supported !!! function=%s", functionName);
		exit(EXIT_FAILURE);
	} /* if */
	return EXIT_SUCCESS;
} /* main */
예제 #4
0
파일: songio.c 프로젝트: cyphus/groove
//assumes SongFolderExists
short CountValidSongs(void)
{
	if (SongCount)
		return SongCount;
	
	SYM_ENTRY *GrvSym;
	
	GrvSym = SymFindFirst(SONGFOLDER, FO_SINGLE_FOLDER);
	
	while (GrvSym)
	{
		if (isValidFile(GrvSym -> handle))
			SongCount++;
		GrvSym = SymFindNext();
	}
	return SongCount;
}
예제 #5
0
파일: roms.cpp 프로젝트: tmaul/FBA4PSP
static int findloop( ROM_FILE_ENT * pre )
{
	int count = 0;
	
	SceUID fd = sceIoDopen(ui_current_path);
	if (fd > 0) {
		memset(&fi, 0, sizeof(fi));
		while ( sceIoDread( fd, &fi ) > 0 ) {
			if ( isValidFile(&fi, pre) ) {
				count++;
				if (pre) pre++;
			}
			memset(&fi, 0, sizeof(fi));
		}
		sceIoDclose(fd);
	}
	return count;
}
예제 #6
0
UInt32 LuaGraphTreeModel::getIndexOfChild(const boost::any& parent, const boost::any& child) const
{
    try
    {
        BoostPath ParentPath = boost::any_cast<BoostPath>(parent);
        BoostPath ChildPath = boost::any_cast<BoostPath>(child);

        if(!ParentPath.empty() &&
           boost::filesystem::exists(ParentPath))
        {
            boost::filesystem::directory_iterator end_iter;
            UInt32 Count(0);
            for ( boost::filesystem::directory_iterator dir_itr( ParentPath ); dir_itr != end_iter; ++dir_itr )
            {
                try
                {
                    if(ChildPath == dir_itr->path() || boost::filesystem::equivalent(dir_itr->path(), ChildPath))
                    {
                        return Count;
                    }
                }
                catch(boost::filesystem::filesystem_error &)
                {
                    return Count;
                }
                if(isValidFile(dir_itr->path()))
                {
                    ++Count;
                }
            }
        }
        return 0;
    }
    catch(boost::bad_any_cast &)
    {
        return 0;
    }
}
예제 #7
0
파일: songio.c 프로젝트: cyphus/groove
//Loads SongHeaders with information needed for songselect menu
//assumes SongFolderExists.
//returns false if memory allocation fails.
short LoadHeaders(void)
{
	short GrvFileIndex = 0;
	short SongHeadersIndex = 0;
	unsigned short *shortPointer = NULL;
	GrvHeader *CurrSongHeader = NULL;
	
	SYM_ENTRY *GrvSym;
	MULTI_EXPR *GrvFile;
	
	SongHeaders = malloc(SongCount * sizeof(GrvHeader));
	if (!SongHeaders)
	{
		return FALSE;
	}
	
	GrvSym = SymFindFirst(SONGFOLDER, FO_SINGLE_FOLDER);
	
	while (GrvSym)
	{
		GrvFile = HeapDeref(GrvSym -> handle);
		if (isValidFile(GrvSym -> handle))
		{
			
			GrvFileIndex = 0;
			CurrSongHeader = &SongHeaders[SongHeadersIndex];
			CurrSongHeader-> SongTitle = &GrvFile-> Expr[GrvFileIndex];
			while (GrvFile-> Expr[GrvFileIndex])
				GrvFileIndex++;
			GrvFileIndex++;
			CurrSongHeader-> SongArtist = &GrvFile-> Expr[GrvFileIndex];
			while (GrvFile-> Expr[GrvFileIndex])
				GrvFileIndex++;
			GrvFileIndex++;
			if (GrvFileIndex % 2)
				GrvFileIndex++;
			
			shortPointer = (unsigned short*)&GrvFile-> Expr[GrvFileIndex];
			CurrSongHeader-> MinBPM = *shortPointer;
			GrvFileIndex += 2;

			shortPointer = (unsigned short*)&GrvFile-> Expr[GrvFileIndex];
			CurrSongHeader-> MaxBPM = *shortPointer;
			GrvFileIndex += 2;

			shortPointer = (unsigned short*)&GrvFile-> Expr[GrvFileIndex];
			CurrSongHeader-> ModeBPM = *shortPointer;
			GrvFileIndex += 2;
			shortPointer = (unsigned short*)&GrvFile-> Expr[GrvFileIndex];
			CurrSongHeader-> DifficultyFlags = *shortPointer;
			GrvFileIndex += 2;
			CurrSongHeader-> DifficultyHeaders = (DifficultyHeader*)&GrvFile-> Expr[GrvFileIndex];
			
			//determine number of difficulties by counting bits set
			//uses Brian Kernighan's method -- thanks!
			unsigned char DiffFlagsForCount = CurrSongHeader-> DifficultyFlags & 0xF800;
			unsigned char DiffCount;
			for (DiffCount = 0; DiffFlagsForCount; DiffCount++)
			{
				DiffFlagsForCount &= DiffFlagsForCount - 1;
			}
			
			GrvFileIndex += DiffCount * sizeof(DifficultyHeader);
			
			CurrSongHeader-> BPMListOffset = GrvFileIndex;
			SongHeadersIndex++;
		}
		GrvSym = SymFindNext();
	}
	return TRUE;
}
예제 #8
0
void processFile(HumdrumFile& infile, const string& filename) {
   int i;
   if (SEGMENTS && !summaryQ) {
      cout << "!!!!SEGMENT: " << infile.getFileName() << endl;
   }

   if (debugQ) {
      cout << "!! file: " << infile.getFileName() << endl;
   }
   if (validQ && !isValidFile(infile)) {
      return;
   }

   if (kernQ) {
      Array<int> ktracks;
      infile.getTracksByExInterp(ktracks, "**kern");
      cout << ktracks.getSize() << endl;
      return;
   }

   if (mdurQ || summaryQ || nograceQ) {
      infile.analyzeRhythm("4");
   }

   Array<int> analysis(infile.getNumLines());
   analysis.setAll(0);
   analysis.allowGrowth(0);
   for (i=0; i<infile.getNumLines(); i++) {
      if (!infile[i].isData()) {
         continue;
      }
      analysis[i] = doAnalysis(infile, i);
   }

   if (summaryQ) {
      return;
   }

   // print analysis:

   int firstdata = 1;
   PerlRegularExpression pre;
   for (i=0; i<infile.getNumLines(); i++) {
      if (appendQ) { cout << infile[i]; }
      if (infile[i].isData()) {
         if (appendQ)  { cout << '\t'; }
         if (measureQ && firstdata) {
            printMeasureData(analysis, infile, i);
            firstdata = 0;
         } else if (measureQ) {
            cout << ".";
         } else {
            if (nograceQ && (infile[i].getDuration() == 0)) {
               cout << ".";
            } else {
               cout << analysis[i];
            }
         }
         if (prependQ) { cout << '\t'; }
         if (appendQ)  { cout << '\n'; }
      } else if (infile[i].isInterpretation()) {
         if (appendQ)  { cout << '\t'; }
         if (strcmp(infile[i][0], "*-") == 0) {
            cout << "*-";
         } else if (strncmp(infile[i][0], "**", 2) == 0) {
            printExclusiveInterpretation();
         } else {
            cout << "*";
         }
         if (prependQ) { cout << '\t'; }
         if (appendQ)  { cout << '\n'; }
      } else if (infile[i].isBarline()) {
         if (pre.search(infile[i][0], "\\d")) {
            firstdata = 1;
         } 
         if (appendQ)  { cout << '\t'; }
         cout << infile[i][0];
         if (prependQ) { cout << '\t'; }
         if (appendQ)  { cout << '\n'; }
      } else if (infile[i].isLocalComment()) {
         if (appendQ)  { cout << '\t'; }
         cout << "!";
         if (prependQ) { cout << '\t'; }
         if (appendQ)  { cout << '\n'; }
      } else {
         if (!(appendQ || prependQ)) { cout << infile[i]; }
         if (appendQ)  { cout << '\n'; }
      }
      if (prependQ) { cout << infile[i]; }
      if (!appendQ) { cout << '\n'; }
   }
}