forked from lee-soft/ViStart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutomaticDestinationsUpdater.cls
107 lines (79 loc) · 2.76 KB
/
AutomaticDestinationsUpdater.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "AutomaticDestinationsUpdater"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private m_lastKnownSizes As Collection
Private m_jumpLists As Collection
Private m_filesFolder As Scripting.Folder
Private m_logger As SeverityLogger
Property Get Logger()
Set Logger = m_logger
End Property
Public Function JumplistsAvailable() As Boolean
JumplistsAvailable = Not m_filesFolder Is Nothing
End Function
Public Function GetImagePathList(ByVal srcImagePath As String)
Dim thisCollection As Collection
Dim thisPath
Dim theResults() As String
Dim resultIndex As Long
Dim thisImagePath
srcImagePath = UCase$(StrEnd(srcImagePath, "\"))
For Each thisCollection In m_jumpLists
For Each thisPath In thisCollection
thisImagePath = DestermineHandler(CStr(thisPath))
If thisImagePath = srcImagePath Then
ReDim Preserve theResults(resultIndex)
theResults(resultIndex) = thisPath
resultIndex = resultIndex + 1
End If
Next
Next
GetImagePathList = theResults
End Function
Private Function UpdateJumplistPaths(theFile As Scripting.File)
Dim newJumplist As Collection
If ExistInCol(m_jumpLists, theFile.Path) Then
m_jumpLists.Remove theFile.Path
End If
Set newJumplist = ParseJumplistFile(theFile.Path)
m_jumpLists.Add newJumplist, theFile.Path
End Function
Public Function Update()
On Error GoTo Handler
Dim thisFile As Scripting.File
For Each thisFile In m_filesFolder.Files
If Not ExistInCol(m_lastKnownSizes, thisFile.Path) Then
UpdateJumplistPaths thisFile
m_lastKnownSizes.Add thisFile.Size, thisFile.Path
ElseIf CLng(m_lastKnownSizes(thisFile.Path)) <> thisFile.Size Then
UpdateJumplistPaths thisFile
m_lastKnownSizes.Remove thisFile.Path
m_lastKnownSizes.Add thisFile.Size, thisFile.Path
End If
Next
Exit Function
Handler:
Logger.Error Err.Description, "Update"
End Function
Private Sub Class_Initialize()
Set m_logger = LogManager.GetCurrentClassLogger(Me)
Dim filesPath As String
Set m_lastKnownSizes = New Collection
Set m_jumpLists = New Collection
filesPath = Environ$("appdata") & "\Microsoft\Windows\Recent\automaticdestinations\"
If FSO.FolderExists(filesPath) Then
Set m_filesFolder = FSO.GetFolder(filesPath)
Update
End If
End Sub