1 #ifndef __BF_NODE_H__
2 #define __BF_NODE_H__
3
4 #include <String.h>
5 #include <Node.h>
6 #include <Entry.h>
7 #include <Bitmap.h>
8 #include "BL_Tools.h"
9
10 #define BF_ROSTER_LOAD_NORMAL 0
11 #define BF_ROSTER_LOAD_TYPE 1
12 #define BF_ROSTER_LOAD_SICON 2
13 #define BF_ROSTER_LOAD_LICON 4
14 #define BF_ROSTER_LOAD_PERMS 8
15 #define BF_ROSTER_LOAD_NODE_DIR 16
16 #define BF_ROSTER_LOAD_NODE_LINK 32
17 #define BF_ROSTER_LOAD_NODE_FILE 64
18 #define BF_ROSTER_LOAD_NODE_PARENTDIR 128
19 #define BF_ROSTER_LOAD_NODE_ALL_REAL (BF_ROSTER_LOAD_NODE_DIR+BF_ROSTER_LOAD_NODE_LINK+BF_ROSTER_LOAD_NODE_FILE)
20 #define BF_ROSTER_LOAD_NODE_ALL (BF_ROSTER_LOAD_NODE_DIR+BF_ROSTER_LOAD_NODE_LINK+BF_ROSTER_LOAD_NODE_FILE+BF_ROSTER_LOAD_NODE_PARENTDIR)
21
22 enum{
23 BF_NODE_TYPE_UNKNOWN=0,
24 BF_NODE_TYPE_FILE,
25 BF_NODE_TYPE_DIR,
26 BF_NODE_TYPE_LINK,
27 BF_NODE_TYPE_PARENTDIR,
28 };
29
30
31 enum{
32 BF_NODE_SELECT_OFF=0,
33 BF_NODE_SELECT_ON,
34 BF_NODE_SELECT_INVERT
35 };
36
37 class BF_NodeCollection;
38 class BF_NodeList;
39
40 #define BF_NODE_STYLE_DEFAULT 0
41
42 class BF_Node:public BL_Object{
43 public:
44 BL_String sName,sType;
45 off_t iSize;
46 time_t uCreateTime,uAccessTime,uModifyTime;
47 int iType;
48 bool bSelect;
49 bool bLink;
50 int32 iStyles;
51 node_ref uNodeRef;
52 mode_t uPerms;
53 BBitmap *poSIcon,*poLIcon;
54 BF_NodeList *ploChild;
55
56 BF_Node(const char *pc_Name=NULL);
57 BF_Node(const BF_Node &o_FromNode,bool b_SetIcon=true);
58 BF_Node(BF_Node *po_FromNode,bool b_SetIcon=true);
59 virtual ~BF_Node();
60
61 void Set(const BF_Node &o_FromNode,bool b_SetIcon=true);
62 void Set(BF_Node *po_FromNode,bool b_SetIcon=true);
63
64 const char* Name() const;
65 int Type() const;
66
67 void PermsTo(BL_String & s_Res) const;
68
69 void SetSelect(uint i_SelectAction);
70 bool CheckByMask(const char *pc_Mask) const;
71 int8 CompareCreateTime(const BF_Node &o_CompNode) const;
72 bool ConvertNameByMask(const BString & s_Mask,BString & s_NewName) const;
73 const BString* ConvertNameByMaskExt(const BString & s_Mask,BString & s_NewName) const;
74
75 void AllocLIcon();
76 void AllocSIcon();
77 void FreeSIcon();
78
79 void CopySIconFrom(BBitmap *po_SIcon);
80
81 private: };
82
83 class BF_Volume:public BF_Node{
84 public:
85 BF_Volume();
86
87 void LoadInfo();
88 bool Load(const char *pc_Name,int i_NodeLoadStyles);
89
90 off_t iCapacity,iFree;
91 bool bBootVolume,bReadOnly,bRemovable,bPersistent,bShared;
92 bool bKnowsQuery;
93 bool bLoadedOk;
94 };
95
96 class BF_Path:public BL_Object{
97 public:
98 static bool GetPathForCurrentApp(BL_String & s_Path);
99
100 BF_Path(const char *pc_Value=NULL);
101 virtual ~BF_Path();
102
103 const char* Path() const;
104 const BL_String String() const;
105 const BL_String PathWFS() const;
106
107 void SetTo(const char *pc_Path);
108 void operator = (const BL_String & s_From);
109 bool operator == (const char *pc_ComparePath) const;
110
111 const BString GetVolume(bool b_CleanVolume=false) const;
112 virtual bool GoParent();
113 virtual bool GoLocalDir(const BString & s_LocalDir);
114
115 bool InFolder(const char *pc_ParentPath) const;
116
117 bool LastDir(BString & s) const;
118 const BL_String LastDir() const;
119 bool Compare(const char *pc_Path);
120
121 bool IsEmpty() const;
122 bool IsVirtualRoot()const ;
123
124 bool IsStorageKit() const;
125
126
127 protected:
128 BL_String sValue;
129
130 friend class BF_FilesPath;
131 };
132
133 class BF_FilesPath:public BF_Path{
134 public:
135 BF_FilesPath(const char *pc_Value=NULL);
136 BF_FilesPath(const BF_Path & o_SrcPath);
137 BF_FilesPath(const BF_FilesPath & o_SrcPath);
138
139 void SetTo(const BF_FilesPath &o_Path);
140 void SetTo(const char *pc_Path,const node_ref *pu_Ref);
141 node_ref& NodeRef() const;
142 BBitmap* LoadSIcon();
143 bool CheckNodeRef(const node_ref & u_NodeRef) const;
144 bool Compare(const BF_FilesPath &o_SomePath);
145
146 void operator = (const BF_FilesPath &o_Path);
147 void operator = (const BF_Path &o_Path);
148
149 virtual bool GoParent();
150 virtual bool GoLocalDir(const BString & s_LocalDir);
151
152 bool IsVolumeReadOnly() const;
153 bool IsExisting() const;
154
155 status_t Create();
156
157 private:
158 node_ref uNodeRef;
159 };
160
161 typedef enum{
162 BF_NODELIST_SORT_NAME=0,
163 BF_NODELIST_SORT_SIZE,
164 BF_NODELIST_SORT_DATE,
165 BF_NODELIST_SORT_TYPE,
166 BF_NODELIST_SORT_EXT,
167 BF_NODELIST_SORT_UNSORTED,
168 BF_NODELIST_SORT_END
169 }BF_NodeList_SortType;
170
171 #define BF_SORT_STYLE_DIRFIRST 1
172
173 #define BF_NODELIST_NODETYPE_NONE 0
174 #define BF_NODELIST_NODETYPE_FILES 1
175 #define BF_NODELIST_NODETYPE_DIRS 2
176 #define BF_NODELIST_NODETYPE_LINKS 4
177 #define BF_NODELIST_NODETYPE_ALL 7
178
179 class BF_NodeCollection:public BL_Collection{
180 public:
181 BF_Path *poPath;
182
183 BF_NodeCollection(bool b_DeleteItems=false);
184 ~BF_NodeCollection();
185
186
187 void CopyTo(BF_NodeCollection & lo_Dest,bool b_CopyIcons) const;
188
189 BF_Node* NodeByName(const char *pc_Name) const;
190 BF_Node* NodeAt(int32 i_Index) const;
191 BF_Node* NodeByRef(node_ref & u_Ref) const;
192 int32 IndexByName(const char *pc_Name) const;
193
194 void SetSelectAll(uint i_SelectAction,const char *pc_Mask=NULL,int i_What=BF_NODELIST_NODETYPE_ALL);
195 uint64 GetSelecting(BF_NodeCollection & lo_Result) const;
196
197 uint64 SizeAll(bool b_WithChilds=false) const;
198 uint64 CountAll(bool b_WithChilds=false) const;
199 uint64 CountRealNodes() const;
200 uint64 CountSelected() const;
201 void SelectedInfo(uint64 & i_Bytes,uint64 & i_Count) const;
202 void LoadChilds(int i_WhatRosterLoad=BF_ROSTER_LOAD_NODE_ALL_REAL);
203
204 void MakePath(const char *pc_Path);
205 void SetSelfPath(BF_Path* po_NewPath);
206
207 void MakeSelfNodes();
208
209 void Sort(BF_NodeList_SortType i_SortType);
210
211 private:
212 bool bSelfPath;
213 public:
214 static uint32 iSortStyle;
215 };
216
217 #define BF_NodeCollection_New(plo_Node,o_Path) BF_NodeCollection *plo_Node;plo_Node = new BF_NodeCollection();plo_Node->SetSelfPath(&o_Path)
218
219 class BF_NodeList:public BF_NodeCollection{
220 public:
221 BF_NodeList(bool b_DeleteItems=true);
222 };
223
224
225
226
227 #endif