Home > Back-end >  How can be shown the placeholder sync icon in a renamed folder using Win32 Cloud Filter API?
How can be shown the placeholder sync icon in a renamed folder using Win32 Cloud Filter API?

Time:09-27

I'm using the Microsoft Sync state icon correctly shown after sync the renamed folder.

Sync state icon isn't visually updated after sync a renamed folder.

Sync state icon isn't visually updated after sync the renamed folder.

CodePudding user response:

you need to call both CfSetInSyncState and CfSetPinState. First set the file in Sync State , and after that update the pin state accordingly.

CodePudding user response:

I could show the placeholder sync icon correctly in this case renaming the folder twice using MoveFileW and CfUpdatePlaceholder functions. Here I show you the method that renames the folder twice.

bool FolderRenameTrick(const std::wstring& folderPath)
{
    // Gets a nonexistent folder path
    std::wstring folderPathAux = GenerateAuxPath(folderPath);

    if (folderPathAux != L"")
    {
        bool renamed = false;
        
        // Renames the folder with MoveFileW method (auxiliary folder)
        if (MoveFile(folderPath.c_str(), folderPathAux.c_str())) 
        {
            // UpdatePlaceholder calls internally to CfUpdatePlaceholder (auxiliary folder)
            if (UpdatePlaceholder(folderPathAux)) 
            {
                renamed = true;
            }
        }

        if (renamed)
        {
            // Renames the folder with MoveFileW method (correct folder)
            if (MoveFile(folderPathAux.c_str(), folderPath.c_str()))
            {
                // UpdatePlaceholder calls internally to CfUpdatePlaceholder (correct folder)
                if (UpdatePlaceholder(folderPath))
                {
                    return true;
                }
            }
        }
    }

    return false;
}
  • Related