mrDarker
2025-08-14 4fb0f6c9b7b0fdfc6cc52c9bf1153d87f92651ca
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "StdAfx.h"
#include "PathData.h"
 
CPathData::CPathData(void)
{
    //»ý¼ºÀÚ ÃʱâÈ­
    InitPathData();
 
    //µðÆúÆ® °ª
    m_strDefaultName = _T("DefaultLog");
    GetModulePath();
}
 
CPathData::~CPathData(void)
{
}
 
CString CPathData::GetNameFromID(int& LogID)
{
    for(int i = 0; i < LV_FCOUNT; i++)
    {
        if( m_nLogID[i] == LogID)
            return    m_strLogName[i];
    }
    return m_strDefaultName;
}
 
CString CPathData::GetPathFromID(int& LogID)
{
    for(int i = 0; i < LV_FCOUNT; i++)
    {
        if( m_nLogID[i] == LogID)
            return    m_strLogPath[i];
    }
    return m_strDefaultPath;
}
 
int CPathData::GetIndexFromID(int& LogID)
{
    for(int i = 0; i < LV_FCOUNT; i++)
    {
        if( m_nLogID[i] == LogID)
            return    i;
    }
    return -1;
}
 
CString CPathData::GetNameFromIndex(int& Index)
{
    return m_strLogName[Index];
}
 
CString CPathData::GetPathFromIndex(int& Index)
{
    return m_strLogPath[Index];
}
 
void CPathData::GetModulePath(void)
{
    TCHAR szBuffer[MAX_PATH];
    memset(szBuffer,0x00,MAX_PATH*sizeof(TCHAR));
 
    ::GetModuleFileName(NULL,szBuffer,MAX_PATH);
 
    for(int i = lstrlen(szBuffer) -1; i>=0; --i)
    {
        if(szBuffer[i] == '\\')
        {
            int j = lstrlen(szBuffer)-1;
            for(;j>=i;--j)
            {
                szBuffer[j] = NULL;
            }
 
            if(szBuffer[j] == ';') szBuffer[j+1] = '\\';
 
            szBuffer[j+1] = '\\';
 
            m_strDefaultPath = szBuffer;
            return;
        }
    }
}
bool CPathData::InsertPathData(int& LogID, CString& strName, CString& strPath)
{
    int InsertIndex = GetEmptyIndex();
    if( InsertIndex == -1)
        return false;
 
    m_nLogID[InsertIndex] = LogID;
    m_strLogName[InsertIndex] = strName;
    m_strLogPath[InsertIndex] = strPath;
    return true;
}
 
int CPathData::GetEmptyIndex(void)
{
    for(int i = 0; i < LV_FCOUNT; i++)
    {
        if( m_nLogID[i] == -1)
            return    i;
    }
    return -1;
}
 
bool CPathData::DeletePathData(int& LogID)
{
    int InsertIndex = GetIndexFromID(LogID);
    if( InsertIndex == -1)
        return false;
 
    m_nLogID[InsertIndex] = -1;
    m_strLogName[InsertIndex] = _T("");
    m_strLogPath[InsertIndex] = _T("");
    return true;
}
 
int CPathData::GetIDFromIndex(int& Index)
{
    if(Index < 0 || Index > LV_FCOUNT) return -1;
    return m_nLogID[Index];
}
 
bool CPathData::SetPathData(int& LogID, CString& strName, CString& strPath)
{
    int index = GetIndexFromID(LogID);
    if( index == -1)    return false;
    SetNameFromIndex(index, strName);
    SetPathFromIndex(index, strPath);
 
    return true;
 
}
 
bool CPathData::SetNameFromIndex(int& index, CString& PathName)
{
    if( index < 0 || index >= LV_FCOUNT)
        return false;
    m_strLogName[index] = PathName;
    return true;
}
 
bool CPathData::SetPathFromIndex(int& index, CString& strPath)
{
    if( index < 0 || index >= LV_FCOUNT)
        return false;
    m_strLogPath[index] = strPath;
    return true;
}
 
bool CPathData::ModifyPathData(int& LogID, CString& strPathName, CString& strLogPath)
{
    return SetPathData(LogID, strPathName, strLogPath);
}
 
void CPathData::InitPathData(void)
{
    for(int i = 0; i < LV_FCOUNT; i++)
    {
        m_nLogID[i] = -1;
        m_strLogPath[i] = _T("");
        m_strLogName[i] = _T("");
    }
}