-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPhotoReference.cpp
executable file
·103 lines (83 loc) · 1.97 KB
/
PhotoReference.cpp
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
#include "StdAfx.h"
#include ".\Defines.h"
#include ".\photoreference.h"
PhotoReference::PhotoReference(const CString& path)
{
ASSERT(ownerThread = ::GetCurrentThreadId());
locked = false;
finished = false;
ZeroMemory(&this->remoteId, sizeof(this->remoteId));
this->path = path;
this->path.Trim();
this->path.FreeExtra();
::GetFileTitle(path, title.GetBuffer(MAX_PHOTO_NAME_LEN),MAX_PHOTO_NAME_LEN);
title.ReleaseBuffer();
int n=0,last=0;
while(-1 != (n = title.Find(_T('.'),last))) last=n+1;
if(last != -1)
title = title.Left(last-1);
title.Trim();
title = title.Left(MAX_PHOTO_NAME_LEN);
//check that title isn't too many digits:
int digits = 0;
for(int i=0;i<title.GetLength();i++)
{
TCHAR c = title[i];
if(c >= _T('0') && c<=_T('9'))
digits++;
}
if(digits >= MAX_DIGITS_TITLE)
title.Empty();
title.FreeExtra();
}
PhotoReference::~PhotoReference(void)
{
PR_ASSERTOWNER;
}
void PhotoReference::Lock()
{
ASSERT(ownerThread == ::GetCurrentThreadId());
this->locked = true;
this->lockedUpdateTitle = this->title;
this->lockedUpdateText = this->text;
}
void PhotoReference::Unlock()
{
ASSERT(ownerThread == ::GetCurrentThreadId());
this->locked = false;
this->SetTitle(this->lockedUpdateTitle);
this->SetText(this->lockedUpdateText);
this->lockedUpdateTitle.Empty();
this->lockedUpdateText.Empty();
}
void PhotoReference::SetTitle(LPCTSTR carg)
{
// PR_ASSERTOWNER;
CString arg = carg;
arg.Trim();
arg.Left(MAX_PHOTO_NAME_LEN);
if(LockedStatus()) {
this->lockedUpdateTitle = arg;
return;
}
if(this->title != arg) {
dirty = true;
this->title = arg;
this->title.FreeExtra();
}
}
void PhotoReference::SetText(LPCTSTR carg)
{
// PR_ASSERTOWNER;
CString arg = carg;
arg.Trim();
if(LockedStatus()) {
this->lockedUpdateText = arg;
return;
}
if(this->text != arg) {
dirty = true;
this->text = arg;
this->text.FreeExtra();
}
}