Example #1
0
void ProcessDirectory(char *szPath)
{
    char szCurPath[MAX_PATH];
    intptr_t hFind;
    __finddata64_t fd;

    strcpy(szCurPath, szPath);
    strcat(szCurPath, "\\*.*");
    hFind = _findfirst64(szCurPath, &fd);
    if (hFind == -1)
        return;

    do
    {
        if (fd.attrib & _A_SUBDIR)
        {
            if (strcmp(fd.name, ".") && strcmp(fd.name, ".."))
            {
                sprintf(szCurPath, "%s\\%s", szPath, fd.name);
                ProcessDirectory(szCurPath);
            }
        }
        else
        {
            sprintf(szCurPath, "%s\\%s", szPath, fd.name);
            ProcessFile(szCurPath);
        }
    } while (_findnext64(hFind, &fd) != -1);

    _findclose(hFind);
}
Example #2
0
//==================================================================
void RibRendToy::addDirToMenu( const char *pDirName, const char *pFilesExt )
{
#if defined(WIN32)

	DStr	buff = DUT::SSPrintFS( "%s/*.%s", pDirName, pFilesExt );

	_finddatai64_t	findData;
	intptr_t	handle = _findfirst64( buff.c_str(), &findData );
	if ( handle != -1 )
	{
		int	ret = 0;
		do
		{
			mTestRibFiles.push_back( findData.name );
			mTestRibFilesPaths.push_back( pDirName );

			glutAddMenuEntry(
				DUT::SSPrintFS( "%s / %s", pDirName, findData.name ).c_str(),
				MENUID_FILES + (int)mTestRibFiles.size()-1 );

			ret = _findnext64( handle, &findData );
		} while ( ret == 0 );

		_findclose( handle );
	}

#elif defined(__linux__)

	DIR	*pDir = opendir( pDirName );
	if ( pDir )
	{
		struct dirent *pDirent;

		while ( pDirent = readdir( pDir ) )
		{
			//pDirent->
		}

		closedir( pDir );
	}

#endif

}
Example #3
0
bool CFileUtil::Deltree( const char *szFolder, bool bRecurse )
{
	bool boRemoveResult(false);

	__finddata64_t fd;
	std::string filespec = szFolder;
	filespec += "*.*";
	intptr_t hfil = 0;
	if ((hfil = _findfirst64(filespec.c_str(), &fd)) == -1)
	{
		return false;
	}
	do
	{
		if (fd.attrib & _A_SUBDIR)
		{
			CString name = fd.name;
			if ((name != ".") && (name != ".."))
			{
				if (bRecurse)
				{
					name = szFolder;
					name += fd.name;
					name += "/";
					Deltree(name.GetBuffer(), bRecurse);
				}
			}
		}
		else
		{
			CString name = szFolder;
			name += fd.name;
			CFileUtil::DeleteFile(name);
		}
	} while(!_findnext64(hfil, &fd));

	_findclose(hfil);

	boRemoveResult=CFileUtil::RemoveDirectory(szFolder);

	return boRemoveResult;
}
// Description:
//
// Arguments:
//
// Return:
//
bool CVisualLog::OpenLogs()
{
	m_sFormat = m_pCVVisualLogImageFormat->GetString();
	m_eFormat = GetFormatType( m_sFormat );
	m_sLogFolder = m_pCVVisualLogFolder->GetString();
	int iLogFolderLen = m_sLogFolder.length();

	// Check we have good params to use
	if ( m_eFormat == EVLF_NONE || iLogFolderLen == 0 )
	{
		GameWarning( "[VisualLog] File format or log folder value invalid" );
		return false;
	}

	// Create base directory if necessary
	CryCreateDirectory( m_sLogFolder );

	// Figure out next number in sequence m_sLogFolderName/m_sLogFolderNameXXXX, where XXXX is 0000, 0001, etc.
	int iSeqNum = 0;
	__finddata64_t fd;
	intptr_t handle = _findfirst64( PathUtil::Make( m_sLogFolder , "*.*" ), &fd );
	if ( handle != -1 )
	{
		do 
		{
			// Is it a directory with our base name as a prefix?
			if ( fd.attrib & _A_SUBDIR && fd.name[0]!='.' && 
					 !_strnicmp( m_sLogFolder, fd.name, iLogFolderLen ) )
			{
				iSeqNum = max( iSeqNum, atoi( fd.name + iLogFolderLen ) + 1 );
			}
		}
		while (0 == _findnext64 (handle, &fd));
		_findclose(handle);
	}

	// Now create directory
	char sLogPath[256];
	_snprintf( sLogPath, sizeof(sLogPath), "%s\\%s%04d", m_sLogFolder.c_str(), m_sLogFolder.c_str(), iSeqNum );
	if ( !CryCreateDirectory( sLogPath ) )
	{
		GameWarning( "[VisualLog] Unable to create directory for log files: %s", sLogPath );
		return false;
	}

	m_sLogPath = sLogPath;
	m_iLogFolderNum = iSeqNum;
	
	char sLogFileName[256];
	_snprintf( sLogFileName, sizeof(sLogFileName), "%s\\%s%04d.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum );	
	char sLogParamsFileName[256];
	_snprintf( sLogParamsFileName, sizeof(sLogParamsFileName), "%s\\%s%04d_params.log", m_sLogPath.c_str(), m_sLogFolder.c_str(), m_iLogFolderNum );	

	// Open Log Files
	m_fLogFile = fxopen(sLogFileName, "w");
	m_fLogParamsFile = fxopen(sLogParamsFileName, "w");
	if ( !m_fLogFile || !m_fLogParamsFile )
	{
		GameWarning( "[VisualLog] Unable to open log files [%s] [%s]", sLogFileName, sLogParamsFileName );
		CloseLogs();
		return false;
	}

	WriteFileHeaders( sLogFileName, sLogParamsFileName );

	return true;
}
Example #5
0
ForceInline void main2(int argc, char **argv)
{
    if (argc < 2)
        return;

    char *path;
    intptr_t hFind;
    __finddata64_t fd;

    iBufferSize = 0x3000;
    gpbBuffer = (uchar *)malloc(iBufferSize);

    for (int i = 1; i != argc; ++i)
    {
        hFind = _findfirst64(argv[i], &fd);
        if (hFind == -1)
            continue;

        do
        {
            path = findpath(argv[i]);
            if (path) *path = 0;

            if (fd.attrib & _A_SUBDIR)
            {
                if (strcmp(fd.name, ".") && strcmp(fd.name, ".."))
                {
                    int j;

                    if (path)
                    {
                        j = strlen(argv[i]);
                        strcpy(&fd.name[j + 1], fd.name);
                        strcpy(fd.name, argv[i]);
                        fd.name[j] = '\\';
                    }

                    ProcessDirectory(fd.name);

                    if (path) *path = '\\';
                }
            }
            else
            {
                int j;

                if (path)
                {
                    j = strlen(argv[i]);
                    strcpy(&fd.name[j + 1], fd.name);
                    strcpy(fd.name, argv[i]);
                    fd.name[j] = '\\';
                }

                ProcessFile(fd.name);

            }

            if (path) *path = '\\';
        } while (_findnext64(hFind, &fd) != -1);
    }

    _findclose(hFind);
    free(gpbBuffer);
}