source: dev/trunk/ab5.0/abdev/abdev/src/ProjectManager/FileManager.cpp@ 681

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

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

File size: 2.5 KB
Line 
1#include "stdafx.h"
2
3using namespace ActiveBasic::PM::FM;
4
5File::File( const std::string &relationalPath, HTREEITEM hTreeItem )
6 : ItemBase( hTreeItem )
7 , relationalPath( relationalPath )
8{
9}
10
11const std::string File::GetFullPath() const
12{
13 return projectInfo.GetWorkDir().GetFullPath( relationalPath );
14}
15
16bool ActiveBasic::PM::FM::Folder::IsEmpty() const
17{
18 BOOST_FOREACH( const ActiveBasic::PM::FM::Folder &folder, folders )
19 {
20 if( !folder.IsEmpty() )
21 {
22 return false;
23 }
24 }
25
26 return files.empty();
27}
28
29void ActiveBasic::PM::FM::Folder::Clear()
30{
31 files.clear();
32 folders.clear();
33}
34
35File &ActiveBasic::PM::FM::Folder::FindFile( HTREEITEM hTreeItem )
36{
37 BOOST_FOREACH( ActiveBasic::PM::FM::Folder &folder, folders )
38 {
39 if( folder.IsExistFile( hTreeItem ) )
40 {
41 return folder.FindFile( hTreeItem );
42 }
43 }
44
45 BOOST_FOREACH( File &file, files )
46 {
47 if( file.GetTreeItemHandle() == hTreeItem )
48 {
49 return file;
50 }
51 }
52 throw;
53}
54
55File &ActiveBasic::PM::FM::Folder::FindFile( const std::string &path )
56{
57 BOOST_FOREACH( ActiveBasic::PM::FM::Folder &folder, folders )
58 {
59 if( folder.IsExistFile( path ) )
60 {
61 return folder.FindFile( path );
62 }
63 }
64
65 BOOST_FOREACH( File &file, files )
66 {
67 if( file.GetRelationalPath() == path || file.GetFullPath() == path )
68 {
69 return file;
70 }
71 }
72 throw;
73}
74
75bool ActiveBasic::PM::FM::Folder::IsExistFile( const std::string &path ) const
76{
77 BOOST_FOREACH( const ActiveBasic::PM::FM::Folder &folder, folders )
78 {
79 if( folder.IsExistFile( path ) )
80 {
81 return true;
82 }
83 }
84
85 BOOST_FOREACH( const File &file, files )
86 {
87 if( file.GetRelationalPath() == path || file.GetFullPath() == path )
88 {
89 return true;
90 }
91 }
92 return false;
93}
94
95bool ActiveBasic::PM::FM::Folder::IsExistFile( HTREEITEM hTreeItem ) const
96{
97 BOOST_FOREACH( const ActiveBasic::PM::FM::Folder &folder, folders )
98 {
99 if( folder.IsExistFile( hTreeItem ) )
100 {
101 return true;
102 }
103 }
104
105 BOOST_FOREACH( const File &file, files )
106 {
107 if( file.GetTreeItemHandle() == hTreeItem )
108 {
109 return true;
110 }
111 }
112 return false;
113}
114
115void ActiveBasic::PM::FM::Folder::Remove( HTREEITEM hTreeItem )
116{
117 BOOST_FOREACH( ActiveBasic::PM::FM::Folder &folder, folders )
118 {
119 if( folder.IsExistFile( hTreeItem ) )
120 {
121 folder.Remove( hTreeItem );
122 return;
123 }
124 }
125
126 for( int i=0; i<static_cast<int>(files.size()); i++ )
127 {
128 if( files[i].GetTreeItemHandle() == hTreeItem )
129 {
130 Jenga::Common::EraseVectorItem<Files>( files, i );
131 return;
132 }
133 }
134 throw;
135}
Note: See TracBrowser for help on using the repository browser.