This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStatusImpl.cpp
More file actions
85 lines (73 loc) · 1.72 KB
/
StatusImpl.cpp
File metadata and controls
85 lines (73 loc) · 1.72 KB
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
#include "stdafx.h"
#include "StatusImpl.h"
#include <vector>
using namespace ATL;
HRESULT MatchKBStatus(LPCWSTR pwszPath, CStringA statusA)
{
if(pwszPath == NULL)
{
return S_FALSE;
}
int pathlen = lstrlen(pwszPath);
int extensionlen = lstrlen(KBFS_EXTENSION);
if(pathlen < extensionlen)
{
return S_FALSE;
}
// See if this is our extension file - skip it if so
if(lstrcmp(pwszPath + (pathlen - extensionlen), KBFS_EXTENSION) == 0)
{
return S_FALSE;
}
CString extPathName = pwszPath;
extPathName += KBFS_EXTENSION;
CAtlFile statusFile;
if(statusFile.Create(extPathName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, 0) != S_OK)
{
return S_FALSE;
}
CStringA targetStatusA;
HRESULT readResult = statusFile.Read(targetStatusA.GetBuffer(statusA.GetLength() + 1), statusA.GetLength());
targetStatusA.ReleaseBuffer();
if (readResult != S_OK)
{
return S_FALSE;
}
if (targetStatusA == statusA)
{
return S_OK;
}
return S_FALSE;
}
template<> CStringA StatusImpl<KBStatus::privateSyncing>::GetStatusLabelA()
{
return CStringA("private syncing");
}
template<> CStringA StatusImpl<KBStatus::privateSynced>::GetStatusLabelA()
{
return CStringA("private synced");
}
template<> CStringA StatusImpl<KBStatus::publicSyncing>::GetStatusLabelA()
{
return CStringA("public syncing");
}
template<> CStringA StatusImpl<KBStatus::publicSynced>::GetStatusLabelA()
{
return CStringA("public synced");
}
template<> int StatusImpl<KBStatus::privateSyncing>::GetIconIndex()
{
return 1;
}
template<> int StatusImpl<KBStatus::privateSynced>::GetIconIndex()
{
return 0;
}
template<> int StatusImpl<KBStatus::publicSyncing>::GetIconIndex()
{
return 3;
}
template<> int StatusImpl<KBStatus::publicSynced>::GetIconIndex()
{
return 2;
}