source: dev/ProjectEditor/CFileInfo.cpp@ 59

Last change on this file since 59 was 3, checked in by dai_9181, 18 years ago
File size: 2.4 KB
Line 
1#include "common.h"
2
3CFileInfo::CFileInfo(char *path,HTREEITEM hTreeItem){
4 m_path=(char *)HeapAlloc(hHeap,0,lstrlen(path)+1);
5 lstrcpy(m_path,path);
6 m_hTreeItem=hTreeItem;
7}
8CFileInfo::~CFileInfo(){
9 HeapDefaultFree(m_path);
10}
11void CFileInfo::GetFullPath(char *buffer){
12 lstrcpy(buffer,m_path);
13 ::GetFullPath(buffer,ProjectInfo.dir);
14}
15
16
17CDBFileInfo::CDBFileInfo(){
18 iNum=0;
19 ppobj_FileInfo=(CFileInfo **)HeapAlloc(hHeap,0,1);
20}
21CDBFileInfo::~CDBFileInfo(){
22 int i;
23 for(i=0;i<iNum;i++){
24 delete ppobj_FileInfo[i];
25 }
26 HeapDefaultFree(ppobj_FileInfo);
27}
28
29void CDBFileInfo::add(char *path,HTREEITEM hTreeItem){
30 ppobj_FileInfo=(CFileInfo **)HeapReAlloc(hHeap,0,ppobj_FileInfo,(iNum+1)*sizeof(CFileInfo *));
31 ppobj_FileInfo[iNum]=new CFileInfo(path,hTreeItem);
32 iNum++;
33}
34void CDBFileInfo::del(HTREEITEM hTreeItem){
35 int i;
36 for(i=0;i<iNum;i++){
37 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem) break;
38 }
39 if(i==iNum) return;
40
41 delete ppobj_FileInfo[i];
42
43 iNum--;
44 for(;i<iNum;i++) ppobj_FileInfo[i]=ppobj_FileInfo[i+1];
45}
46char *CDBFileInfo::GetPath(HTREEITEM hTreeItem){
47 int i;
48 for(i=0;i<iNum;i++){
49 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem) break;
50 }
51 if(i==iNum) return 0;
52 return ppobj_FileInfo[i]->m_path;
53}
54BOOL CDBFileInfo::IsMainFile(HTREEITEM hTreeItem){
55 int i;
56 for(i=0;i<iNum;i++){
57 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem) break;
58 }
59 if(i==0) return 1;
60 return 0;
61}
62void CDBFileInfo::SetTreeItem(int index,HTREEITEM hTreeItem){
63 ppobj_FileInfo[index]->m_hTreeItem=hTreeItem;
64}
65void CDBFileInfo::ResetTree(void){
66 TV_INSERTSTRUCT tv;
67
68 TreeView_DeleteAllItems(pobj_FileTree->hTree);
69
70 tv.hInsertAfter=TVI_SORT;
71 tv.item.mask=TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
72
73 tv.hParent=TVI_ROOT;
74 tv.item.iImage=0;
75 tv.item.iSelectedImage=0;
76 tv.item.pszText="Source Files";
77 tv.hParent=TreeView_InsertItem(pobj_FileTree->hTree,&tv);
78
79 int i;
80 char temporary[MAX_PATH],temp2[MAX_PATH];
81 for(i=0;i<iNum;i++){
82 _splitpath(ppobj_FileInfo[i]->m_path,0,0,temporary,temp2);
83 lstrcat(temporary,temp2);
84 tv.item.iImage=2;
85 tv.item.iSelectedImage=2;
86 tv.item.pszText=temporary;
87 ppobj_FileInfo[i]->m_hTreeItem=TreeView_InsertItem(pobj_FileTree->hTree,&tv);
88 }
89}
90BOOL CDBFileInfo::dupli_check(char *path){
91 //重複チェック
92 int i;
93 for(i=0;i<iNum;i++){
94 if(lstrcmpi(ppobj_FileInfo[i]->m_path,path)==0){
95 return 1;
96 }
97 }
98 return 0;
99}
Note: See TracBrowser for help on using the repository browser.