source: dev/trunk/ab5.0/abdev/abdev/CFileInfo.cpp@ 653

Last change on this file since 653 was 653, checked in by dai_9181, 16 years ago

FileTreeView周りをリファクタリング

File size: 1.6 KB
Line 
1#include "stdafx.h"
2
3#include "common.h"
4
5CFileInfo::CFileInfo( const std::string &filepath, HTREEITEM hTreeItem )
6 : filepath( filepath )
7 , m_hTreeItem( hTreeItem )
8{
9}
10void CFileInfo::GetFullPath(char *buffer){
11 lstrcpy(buffer,this->GetPath().c_str());
12 lstrcpy( buffer, projectInfo.GetWorkDir().GetFullPath( buffer ).c_str() );
13}
14
15
16CDBFileInfo::CDBFileInfo(){
17 iNum=0;
18 ppobj_FileInfo=(CFileInfo **)HeapAlloc(hHeap,0,1);
19}
20CDBFileInfo::~CDBFileInfo(){
21 int i;
22 for(i=0;i<iNum;i++){
23 delete ppobj_FileInfo[i];
24 }
25 HeapDefaultFree(ppobj_FileInfo);
26}
27
28void CDBFileInfo::add(char *path,HTREEITEM hTreeItem){
29 ppobj_FileInfo=(CFileInfo **)HeapReAlloc(hHeap,0,ppobj_FileInfo,(iNum+1)*sizeof(CFileInfo *));
30 ppobj_FileInfo[iNum]=new CFileInfo(path,hTreeItem);
31 iNum++;
32}
33void CDBFileInfo::del(HTREEITEM hTreeItem){
34 int i;
35 for(i=0;i<iNum;i++){
36 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem) break;
37 }
38 if(i==iNum) return;
39
40 delete ppobj_FileInfo[i];
41
42 iNum--;
43 for(;i<iNum;i++) ppobj_FileInfo[i]=ppobj_FileInfo[i+1];
44}
45const std::string &CDBFileInfo::GetPath(HTREEITEM hTreeItem)
46{
47 for( int i=0; i<iNum; i++ )
48 {
49 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem)
50 {
51 return ppobj_FileInfo[i]->GetPath();
52 }
53 }
54
55 _ASSERTE( false );
56 throw;
57}
58BOOL CDBFileInfo::IsMainFile(HTREEITEM hTreeItem){
59 int i;
60 for(i=0;i<iNum;i++){
61 if(ppobj_FileInfo[i]->m_hTreeItem==hTreeItem) break;
62 }
63 if(i==0) return 1;
64 return 0;
65}
66BOOL CDBFileInfo::dupli_check(char *path){
67 //重複チェック
68 int i;
69 for(i=0;i<iNum;i++){
70 if(lstrcmpi(ppobj_FileInfo[i]->GetPath().c_str(),path)==0){
71 return 1;
72 }
73 }
74 return 0;
75}
Note: See TracBrowser for help on using the repository browser.