コード例 #1
0
void CDuiFrameWnd::OnDropFiles( HWND hwnd, HDROP hDropInfo )
{
    UINT  nFileCount = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
    TCHAR szFileName[_MAX_PATH] = _T("");
    DWORD dwAttribute;
    std::vector<PlayFileInfo> vctString;

    // 获取拖拽进来文件和文件夹
    for (UINT i = 0; i < nFileCount; i++)
    {
        ::DragQueryFile(hDropInfo, i, szFileName, sizeof(szFileName));
        dwAttribute = ::GetFileAttributes(szFileName);

        // 是否为文件夹
        if ( dwAttribute & FILE_ATTRIBUTE_DIRECTORY )
        {          
            ::SetCurrentDirectory(szFileName);       
            EnumerateFiles(vctString);	      
        }
        else
        {
			PlayFileInfo tempPlayFileInfo;
			wcscpy(tempPlayFileInfo.szFileName, szFileName);
			tempPlayFileInfo.nPos = 0;
            vctString.push_back(tempPlayFileInfo);
        }
    }

    AddFiles(vctString);
    ::DragFinish(hDropInfo);
}
コード例 #2
0
///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
void FireEventForEachFileFound( const std::string& eventToFire, const std::string& directory, const std::string& searchPattern, bool recurseSubfolders )
{
    Strings files;
    EnumerateFiles( directory, searchPattern, files, recurseSubfolders );

    for (std::string& file : files)
    {
        std::string fileWithoutPath = ExtractFileNameFromPath( file );
        std::string fileName = RemoveFileExtension( fileWithoutPath );
        Strings fileNameTokens;
        Tokenize( fileWithoutPath, fileNameTokens, "." );
        std::string fileExtension = "." + fileNameTokens[1];
        std::string relativePath = ConvertBackSlashesToForwardSlashes( file );
        char fullPath[_MAX_PATH];
        _fullpath( fullPath, relativePath.c_str(), _MAX_PATH );
        std::string fullFilePath = ConvertBackSlashesToForwardSlashes( std::string( fullPath ) );

        ConsolePrintf( "File without path:  %s\n File Name: %s\n File Extension: %s\n File Relative: %s\n File Absolute: %s\n", fileWithoutPath.c_str(), fileName.c_str(), fileExtension.c_str(), relativePath.c_str(), fullFilePath.c_str() );

        NamedProperties props;
        props.Set( "FileName", fileWithoutPath );
        props.Set( "FileExtension", fileExtension );
        props.Set( "FileNameWithoutExtension", fileName );
        props.Set( "FileRelativePath", relativePath );
        props.Set( "FileAbsolutePath", fullFilePath );

        FireEvent( eventToFire, props );
    }
}
コード例 #3
0
ファイル: win_savegame.cpp プロジェクト: 469486139/DOOM-3-BFG
/*
========================
idSaveGameThread::Run
========================
*/
int idSaveGameThread::Run() {
	int ret = ERROR_SUCCESS;

	try {
		idLocalUserWin * user = GetLocalUserFromSaveParms( data );
		if ( user != NULL && !user->IsStorageDeviceAvailable() ) {
			data.saveLoadParms->errorCode = SAVEGAME_E_UNABLE_TO_SELECT_STORAGE_DEVICE;
		}

		if ( savegame_winInduceDelay.GetInteger() > 0 ) {
			Sys_Sleep( savegame_winInduceDelay.GetInteger() );
		}

		if ( data.saveLoadParms->mode & SAVEGAME_MBF_SAVE ) {
			ret = Save();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_LOAD ) {
			ret = Load();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE ) {
			ret = Enumerate();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FOLDER ) {
			ret = Delete();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_ALL_FOLDERS ) {
			ret = DeleteAll();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FILES ) {
			ret = DeleteFiles();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE_FILES ) {
			ret = EnumerateFiles();
		}

		// if something failed and no one set an error code, do it now.
		if ( ret != 0 && data.saveLoadParms->errorCode == SAVEGAME_E_NONE ) {
			data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
		}
	} catch ( ... ) {
		// if anything horrible happens, leave it up to the savegame processors to handle in PostProcess().
		data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
	}

	// Make sure to cancel any save game file pipelines.
	if ( data.saveLoadParms->errorCode != SAVEGAME_E_NONE ) {
		data.saveLoadParms->CancelSaveGameFilePipelines();
	}

	// Override error if cvar set
	if ( savegame_error.GetInteger() != 0 ) {
		data.saveLoadParms->errorCode = (saveGameError_t)savegame_error.GetInteger();
	}

	// Tell the waiting caller that we are done
	data.saveLoadParms->callbackSignal.Raise();

	return ret;
}
コード例 #4
0
ファイル: AddListDlg.cpp プロジェクト: danieljennings/p4win
void CAddListDlg::Init(CStringList *strList, CStringList *changeList, 
					   LPCTSTR selChange, BOOL bEditAndAdd, int key)
{
	ASSERT_KINDOF(CStringList, strList);
	m_pStrList=strList;
	m_pChangeList=changeList;
	m_SelChange= selChange;
	m_bEditAndAdd= bEditAndAdd;
	m_Initialized=TRUE;
	m_DeletedRows=FALSE;
    m_UserTerminated=FALSE;
	m_Key=key;

	/////////////////////////////////
	// Enumerate the files before the dialog window is crafted
	EnumerateFiles();
}
コード例 #5
0
void EnumerateFiles(std::vector<PlayFileInfo> &vctString)
{
    WIN32_FIND_DATA fd;
    HANDLE hFind = ::FindFirstFile(_T("*.*"), &fd);

    if (hFind != INVALID_HANDLE_VALUE)
    {
        do 
        {
            // 如果为目录
            if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
            {
                if (_tcscmp(fd.cFileName, _T(".")) && _tcscmp(fd.cFileName, _T("..")))
                {
                    ::SetCurrentDirectory(fd.cFileName);    
                    EnumerateFiles(vctString);              
                    ::SetCurrentDirectory(_T(".."));        
                }
            }
            // 如果为文件
            else
            {
                CDuiString strDir;
                TCHAR      lpDir[MAX_PATH];

                ::GetCurrentDirectory(MAX_PATH, lpDir);
                strDir = lpDir;
                if ( strDir.Right(1) != _T("\\") )
                {
                    strDir += _T("\\");
                }
                strDir += fd.cFileName;
				PlayFileInfo tempPlayFileInfo;
				wcscpy(tempPlayFileInfo.szFileName, strDir.GetData());
				tempPlayFileInfo.nPos = 0;
                vctString.push_back(tempPlayFileInfo);
            }
        } while (::FindNextFile(hFind, &fd));

        ::FindClose(hFind);
    }
}
コード例 #6
0
ファイル: FileUtil.cpp プロジェクト: boyisgood86/Redrain-
void CFileUtil::EnumerateFiles(vector<CDuiString> &vctString)
{
	WIN32_FIND_DATA fd;
	HANDLE hFind = ::FindFirstFile(_T("*.*"), &fd);

	if (hFind != INVALID_HANDLE_VALUE)
	{
		do 
		{
			// 如果为目录
			if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				if (_tcscmp(fd.cFileName, _T(".")) && _tcscmp(fd.cFileName, _T("..")))
				{
					::SetCurrentDirectory(fd.cFileName);    
					EnumerateFiles(vctString);              
					::SetCurrentDirectory(_T(".."));        
				}
			}
			// 如果为文件
			else
			{
				CDuiString strDir;
				TCHAR      lpDir[MAX_PATH];

				::GetCurrentDirectory(MAX_PATH, lpDir);
				strDir = lpDir;
				if ( strDir.Right(1) != _T("\\") )
				{
					strDir += _T("\\");
				}
				strDir += fd.cFileName;
				if (CFileUtil::FindFileExt(strDir.GetData(), STR_SUPPORT_FILE_EXT))
					vctString.push_back(strDir.GetData());
			}
		} while (::FindNextFile(hFind, &fd));

		::FindClose(hFind);
	}

}
コード例 #7
0
ファイル: Storage.c プロジェクト: 0xE0F/ir-system
/** Пеерчисление файлов */
FRESULT EnumerateFiles ( char* path, action_on_enum_t func)
{
    FRESULT res;
    FILINFO fno;
    DIR dir;
    int i;
    char *fn;   /* This function is assuming non-Unicode cfg. */
#if _USE_LFN
    static char lfn[_MAX_LFN + 1];
    fno.lfname = lfn;
    fno.lfsize = sizeof(lfn);
#endif


    res = f_opendir(&dir, path);                       /* Open the directory */
    if (res == FR_OK) {
        i = strlen(path);
        for (;;) {
            res = f_readdir(&dir, &fno);                   /* Read a directory item */
            if (res != FR_OK || fno.fname[0] == 0) break;  /* Break on error or end of dir */
            if (fno.fname[0] == '.') continue;             /* Ignore dot entry */
#if _USE_LFN
            fn = *fno.lfname ? fno.lfname : fno.fname;
#else
            fn = fno.fname;
#endif
            if (fno.fattrib & AM_DIR) {                    /* It is a directory */
                sprintf(&path[i], "/%s", fn);
                res = EnumerateFiles(path, func);
                if (res != FR_OK) break;
                path[i] = 0;
            } else {                                       /* It is a file. */
                if (func)
                	func(path, fn);
            }
        }
    }

    return res;
}
コード例 #8
0
ファイル: md5index.c プロジェクト: hammackj/wintools
/**
 * Main entry point for MD5Index.
 *
 * @author Jacob Hammack
 *
 */
int _tmain(int argc, TCHAR *argv[])
{
	
	errno_t err;
	
	printf("MD5Index v1.0\nCopyright 2008 Jacob Hammack\nhttp://www.hammackj.com\n\n");
	
	err = _tfopen_s(&fp, TEXT("MD5Index.dat"), TEXT("w"));
	
	if((err != 0) || (fp == NULL))
	{
		return -1;
	}
	
	printf("[*] Building Index....\n");
	
	EnumerateFiles();
	

	printf("[!] Indexing Complete\n");

	return 0;		
}
コード例 #9
0
ファイル: CpioArchive.cpp プロジェクト: djp952/vm-linux
void CpioArchive::EnumerateFiles(StreamReader&& reader, std::function<void(CpioFile const&)> func)
{
	return EnumerateFiles(&reader, func);
}
コード例 #10
0
ファイル: Storage.c プロジェクト: 0xE0F/ir-system
/** Очистка хранилища */
void EraseStorage(void)
{
	char path[259] = {"0:"};
	EnumerateFiles(path, EraseCallBack);
}
コード例 #11
0
ファイル: Storage.c プロジェクト: 0xE0F/ir-system
// Отображение содержимого хранилища
void PrintConentStorage(void)
{
	char path[259] = {"0:"};
	EnumerateFiles(path, PrintCallBack);
}
コード例 #12
0
	void InstalledFontList::Load()
	{
		if (isLoaded) return;
		isLoaded = true;

		std::vector<std::string> paths;
#ifdef _WIN32
		EnumerateFiles("C:\\Windows\\Fonts\\", paths);
#elif defined __APPLE__
		EnumerateFiles("/System/Library/Fonts/", paths);
		EnumerateFiles("/Library/Fonts/", paths);
#endif

		FT_Library library = nullptr;
		auto error = FT_Init_FreeType(&library);

		for (auto& path : paths)
		{
			auto ext_ = GetFileExt(path.c_str());
			std::string ext(ext_);
			std::transform(ext_.begin(), ext_.end(), ext.begin(), tolower_);

			// fonはアウトラインでないので未対応
			if (ext == std::string("fon"))
			{
				continue;
			}

			FT_Face face = nullptr;
			FT_New_Face(library, path.c_str(), 0, &face);
			if (face == nullptr) continue;

			Font font;
			font.Name = ToAString(face->family_name);
			font.Path = ToAString(path.c_str());

			Fonts.push_back(font);

			FT_Done_Face(face);
		}

		FT_Done_FreeType(library);

		// レジストリだとフルネームが長い
		/*
		HKEY fontKey;

		// レジストリを開く
		auto r = RegOpenKeyExA(
			HKEY_LOCAL_MACHINE,
			"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
			0,
			KEY_READ,
			&fontKey);

		if (r != ERROR_SUCCESS) return;

		for (auto ind = 0;; ind++)
		{
			char valueName[1000];
			DWORD valueNameSize = 1000;

			char value[1000];
			DWORD valueSize = 1000;

			DWORD valueType;

			auto result = SHEnumValueA(
				fontKey,
				ind,
				valueName,
				&valueNameSize,
				&valueType,
				value,
				&valueSize);

			if (result != ERROR_SUCCESS) break;

			Font font;
			font.Name = ToAString(valueName);
			font.Path = ToAString(value);

			Fonts.push_back(font);
		}

		// 終了
		RegCloseKey(fontKey);
		*/
	}