Beispiel #1
0
	/**
		@brief	拡張子ごとのファイル検索
		@param	tszPath	検索するパス
		@param	tszExt	拡張子フィルタ
		@param	nStart	リストの追加位置
	 */
	void	searchFileExt( const _TCHAR* tszPath, const _TCHAR* tszExt, size_t nStart )
	{
		WIN32_FIND_DATA	ffd;
		tstring	tstrPathExt = tszPath;
		AddFilename( tstrPathExt, tszExt );

		HANDLE	hFind = FindFirstFile( tstrPathExt.c_str(), &ffd );

		if( hFind == INVALID_HANDLE_VALUE )
		{

		} else {
			do {
				if( ~ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
				{
					tstring	tstrFName = tszPath;
					AddFilename( tstrFName, ffd.cFileName );

					if( !isDuplication( tstrFName, nStart ) )
					{
						m_vecFilelist.push_back( tstrFName );
					}
				}

			} while( FindNextFile( hFind, &ffd) != 0 );

			FindClose( hFind );
		}


	}
Beispiel #2
0
	/**
		@brief	サブディレクトリを検索
		@param	tszPath		検索するパス
		@note	サブディレクトリを検索し、リストにファイル名を追加する
	 */
	void	searchDirectory( const _TCHAR* tszPath )
	{	
		WIN32_FIND_DATA	ffd;

		tstring	tstrPath = tszPath;
		AddFilename( tstrPath, "*.*" );

		HANDLE	hFind = FindFirstFile( tstrPath.c_str(), &ffd );

		if( hFind == INVALID_HANDLE_VALUE )
		{

		} else {
			do {
				if( ffd.cFileName[0] == _T('.') )continue;

				if( ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
				{
					std::string	tstrNewPath = tszPath;
					AddFilename( tstrNewPath, ffd.cFileName );
					search( tstrNewPath.c_str() );
				}

			} while( FindNextFile( hFind, &ffd) != 0 );

			FindClose( hFind );
		}
	}
Beispiel #3
0
bool xZipAddFile( const char* filename, CUtlBuffer &fileBuff, bool bPrecacheEntireFile, bool bProcessPrecacheHeader, bool bProcessPrecacheHeaderOnly )
{
    unsigned int fileSize = fileBuff.TellMaxPut();

    // Track total input bytes for stats reasons
    InputFileBytes += fileSize;

    unsigned customPreloadSize = 0;

    if( bPrecacheEntireFile  )
    {
        customPreloadSize = fileSize;
    }
    else if( bProcessPrecacheHeader )
    {
        customPreloadSize = xZipComputeCustomPreloads( filename );
    }
    else if( bProcessPrecacheHeaderOnly )
    {
        customPreloadSize = xZipComputeCustomPreloads( filename );
        fileSize = min( fileSize, customPreloadSize );
    }

    unsigned CRC = xZipCRCFilename( filename );

    // Does this file have a split header?
    if( customPreloadSize > 0  )
    {
        // Initialize the entry header:
        xZipDirectoryEntry_t entry;
        memset( &entry, 0, sizeof( entry ) );

        entry.FilenameCRC = CRC;
        entry.Length = customPreloadSize;
        entry.StoredOffset = ftell(hTempFilePreload);

        // Add the directory entry to the preload table:
        Header.PreloadDirectoryEntries++;
        pPreloadDirectoryEntries = (xZipDirectoryEntry_t*)realloc( pPreloadDirectoryEntries, sizeof( xZipDirectoryEntry_t ) * Header.PreloadDirectoryEntries );
        memcpy( pPreloadDirectoryEntries + Header.PreloadDirectoryEntries - 1, &entry, sizeof( entry ) );

        // Concatenate the data in the preload file:
        fileBuff.SeekGet( CUtlBuffer::SEEK_HEAD, 0 );
        WriteFileBytes( hTempFilePreload, fileBuff, entry.Length );
        fileBuff.SeekGet( CUtlBuffer::SEEK_HEAD, 0 );


        // Add the filename entry:
        AddFilename( filename );

        // Spew it:
        printf("+Preload: \"%s\": Length:%u\n", filename, entry.Length );
    }

    // Copy the file to the regular data region:
    xZipDirectoryEntry_t entry;
    memset(&entry,0,sizeof(entry));
    entry.FilenameCRC = CRC;
    entry.Length = fileSize;
    entry.StoredOffset = ftell(hTempFileData);

    // Add the directory entry to the table:
    Header.DirectoryEntries++;
    pDirectoryEntries = (xZipDirectoryEntry_t*)realloc( pDirectoryEntries, sizeof( xZipDirectoryEntry_t ) * Header.DirectoryEntries );
    memcpy( pDirectoryEntries + Header.DirectoryEntries - 1, &entry, sizeof( entry ) );

    WriteFileBytes( hTempFileData, fileBuff, entry.Length );

    // Align the data region to a 512 byte boundry:  (has to be on last entry as well to ensure enough space to perform the final read,
    // and initial alignment is taken careof by assembexzip)
    int nPadding = ( XBOX_HDD_SECTORSIZE - ( ftell( hTempFileData ) % XBOX_HDD_SECTORSIZE) ) % XBOX_HDD_SECTORSIZE;

    PadFileBytes( hTempFileData, nPadding );

    // Add the file to the file string table:
    AddFilename( filename );

    // Print a summary
    printf("+File: \"%s\": Length:%u Padding:%i\n", filename,  entry.Length, nPadding );

    return true;
}