Exemplo n.º 1
0
void Platform::FindFileInDir(tWStringList &alstStrings,tWString asDir, tWString asMask)
{
    //Log("Find Files in '%ls' with mask '%ls'\n",asDir.c_str(), asMask.c_str());
    //Get the search string
    wchar_t sSpec[256];
    wchar_t end = asDir[asDir.size()-1];
    //The needed structs
    DIR *dirhandle;
    dirent *_entry;
    struct stat statbuff;
    tWString fileentry;

    if ((dirhandle = opendir(cString::To8Char(asDir).c_str()))==NULL) return;

    while ((_entry = readdir(dirhandle)) != NULL)
        {
            if (end==_W('/'))
                swprintf(sSpec,256,_W("%ls%s"),asDir.c_str(),_entry->d_name);
            else
                swprintf(sSpec,256,_W("%ls/%s"),asDir.c_str(),_entry->d_name);

            // skip unreadable
            if (stat(cString::To8Char(sSpec).c_str(),&statbuff) ==-1) continue;
            // skip directories
            if (S_ISDIR(statbuff.st_mode)) continue;

            fileentry.assign(cString::To16Char(_entry->d_name));

            if (!patiMatch(asMask.c_str(),fileentry.c_str())) continue;
            alstStrings.push_back(fileentry);
        }
    closedir(dirhandle);
}
Exemplo n.º 2
0
	void CopyTextToClipboard(const tWString &asText)
	{
#ifdef WIN32
		OpenClipboard(NULL);
		EmptyClipboard();

		HGLOBAL clipbuffer;
		wchar_t * pBuffer;
		EmptyClipboard();
		clipbuffer = GlobalAlloc(GMEM_DDESHARE, (asText.size()+1) *sizeof(wchar_t));
		pBuffer = (wchar_t*)GlobalLock(clipbuffer);
		wcscpy(pBuffer, asText.c_str());
		//GlobalUnlock(clipbuffer);

		SetClipboardData(CF_UNICODETEXT, clipbuffer);

		GlobalUnlock(clipbuffer); 
		
		CloseClipboard();
#endif
	}