Page MenuHomePhabricator

Public | Replicate folder attributes so custom folder icon will display in destination (desktop.ini)
Closed, ResolvedPublic

Description

Rick opened ticket:

When using replicator, it does not copy custom folder icons - but merely recreates the data with a new generic default folder icon. Should I change an existing target folder and customize it, the next time I run replicator, it changes it back from the customized folder icon to the default icon.

In order for a folder to display a custom icon:

  • the hidden system file desktop.ini must be there
  • the folder itself must have the readonly attribute set

The Global Exclusions can be adjusted to allow copy of Desktop.ini files, but the custom icon setting won't be acknowledged because Replicator doesn't set the destination folder attributes to match the source.

Event Timeline

Joe created this task.Jan 5 2019, 2:02 PM
Joe created this object in space S5 Public.
Joe triaged this task as Normal priority.
Joe created this object with visibility "Public (No Login Required)".
Joe added a comment.EditedJan 5 2019, 2:17 PM

Why it doesn't work:

Y:\Folder Test>attrib /d "Folder Icon"\*
A  SH                Y:\Folder Test\Folder Icon\desktop.ini
A                    Y:\Folder Test\Folder Icon\New Text Document.txt

Y:\Folder Test>attrib /d "Folder Icon"
A                    Y:\Folder Test\Folder Icon

To make Explorer pay attention to desktop.ini, the folder itself needs readonly attribute set:

Y:\Folder Test>attrib /d "Folder Icon" +r

Y:\Folder Test>attrib /d "Folder Icon"
A    R               Y:\Folder Test\Folder Icon

Joe closed this task as Resolved.Jan 5 2019, 5:03 PM
Public Function MakeDir(Dir As String, Attrs As Long) As Boolean
    Dim sa() As String
    Dim s As String
    Dim i As Long
    Dim result As Long

    If ApiFolderExists(Dir, frmMain.dirTest) Then
        On Error Resume Next
        ' 20190105 JMW https://phabricator.karenware.com/T116
        '    PT_ATTR_READONLY set on folders containing desktop.ini customizations
        '    ApiAttrsSet Dir, Attrs And PT_ATTR_DEFAULT_FOLDER
        ApiAttrsSet Dir, Attrs And (PT_ATTR_DEFAULT_FOLDER Or PT_ATTR_READONLY)
        ApiLastError = 0
        MakeDir = True
        Err.Clear
        Exit Function
    End If

    sa = Split(Dir, "\")
    If Left(Dir, 2) = "\\" Then '  UNC
        s = "\\" & sa(2) & "\"
        i = 3
    Else
        s = ""
        i = 0
    End If

    On Error Resume Next
    For i = i To UBound(sa)
        s = s & sa(i) & "\"
        If Len(sa(i)) > 0 Then
            If Not ApiFolderExists(s, frmMain.dirTest) Then
                ' 20190105 JMW https://phabricator.karenware.com/T116
                '     Should create with source folder attributes + archive, IMHO, but
                '     afraid of rocking the boat too much, so carry forward the READONLY bit alone
                '     If Not ApiFolderCreate(s, PT_ATTR_ARCHIVE Or PT_ATTR_NORMAL) Then
                If Not ApiFolderCreate(s, PT_ATTR_ARCHIVE Or PT_ATTR_NORMAL _
                    Or (Attrs And PT_ATTR_READONLY)) Then
                    MakeDir = False
                    Exit Function
                End If
                TempFolderCreateCnt = TempFolderCreateCnt + 1
                LogCreate s
            End If
        End If
    Next i

    MakeDir = True
    Err.Clear
End Function