Question

Given the following code I need it to work on a Korean/Japanese Windows SO. It just dosen't work, and i cant tell why...

May You guys help me out?

void RecurseSearch(LPCTSTR pstr, CString serchTerm, CSimpleMap<CString,CString>* arr)
{
    CFileFind finder;
    // build a string with wildcards
    CString strWildcard;
    int code_point =  0x5c ;
    WCHAR chr = (WCHAR) code_point;
    strWildcard.Format(_T("%s%c*%s*"), pstr,chr,serchTerm);
    CString actualFolder;
    // start working for files
    BOOL bWorking = finder.FindFile(strWildcard);

    while (bWorking)
    {

        bWorking = finder.FindNextFile();
        actualFolder=finder.GetFilePath();
        // skip . and .. files; otherwise, we'd
        // recur infinitely!

        if (finder.IsDots())
            continue;

        // if it's a directory, recursively search it

        else if (finder.IsDirectory())
        {
            CString str = finder.GetFilePath();
            RecurseSearch(str, serchTerm, arr);
        }
        else
        {
            if(arr->GetSize()>200) return;
            if(arr->FindKey(finder.GetFileURL())==-1)
                arr->Add(finder.GetFileURL(),finder.GetFileURL());
        }
    }
    bWorking = finder.FindFile(pstr+(CString)chr+(CString)_T("*"));
    while(bWorking)
    {
        bWorking = finder.FindNextFile();
        actualFolder =finder.GetFilePath();
        if (!finder.IsDirectory() || finder.IsDots()) continue;
        else
        {
            RecurseSearch(actualFolder, serchTerm, arr);
        }

    }
    finder.Close();
}

this code works just fine on a American Windows, but doesn't on Korean ... I even set the path separator to the correct unicode but nothing...

EDIT: I've identified the error, it was relative to ItemNames and ItemDisplayNames. I need to search for ItemDisplayNames but the CFindFile search for ItemName.

I change the code to use ISearchFolderItemFactory and then perform a AQS query.

TY Guys anyway!

Was it helpful?

Solution

Use backslash for the path separator. Regardless of the current language, backslash is documented as accepted in all cases. It could be MFC is screwing things up...

Here are two links that should help.

http://msdn.microsoft.com/en-us/library/dd317748(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#naming_conventions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top