Develop and Download Open Source Software

Browse Subversion Repository

Contents of /filemv/dir.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download)
Wed Jan 2 22:06:47 2008 UTC (16 years, 3 months ago) by tabasa
File MIME type: text/plain
File size: 5122 byte(s)


1 #include "defextern.h"
2
3 #include "myfilemv.h"
4 #include "initial.h"
5 #include "tab.h"
6 #include "file.h"
7
8 BOOL ismouse(char *d)
9 {
10 return (strncmp(_MOUSE, d, strlen(_MOUSE))==0);
11 }
12
13 BOOL isclip(char *d)
14 {
15 return (strncmp(_CLIP, d, strlen(_CLIP))==0);
16 }
17
18 BOOL ishis(char *d)
19 {
20 return (strncmp(_HIS, d, strlen(_HIS))==0);
21 }
22
23 BOOL ismain(char *d)
24 {
25 BOOL i=(strncmp(_MAIN_FOLDER, d, strlen(_MAIN_FOLDER))==0);
26 BOOL j=(strncmp(_ROOT_FOLDER, d, strlen(_ROOT_FOLDER))==0);
27 return (i||j);
28 }
29
30 BOOL dirw::ismouse()
31 {
32 mousef =::ismouse(dir);
33 return mousef;
34 }
35
36 BOOL dirw::isclip()
37 {
38 clipf =::isclip(dir);
39 return clipf;
40 }
41
42 BOOL dirw::ismain()
43 {
44 mainf =::ismain(dir);
45 return mainf;
46 }
47
48 BOOL dirw::ishis()
49 {
50 hisf =::ishis(dir);
51 if(strlen(dir)<5 || dir[4]=='R' || dir[4]=='r') hisRf =TRUE;
52 else hisLf =TRUE;
53 return hisf;
54 }
55
56
57 char clipdirfile[MAX_PATH];
58 #define keydir "dir"
59 #define keydirnum "num"
60
61 // clip:abc >> abc.ini ‚ɐݒč
62
63 void initclip(char *dir)
64 {
65 wsprintf(clipdirfile,"%s\\%s.ini",getCdir(), dir+5);
66 }
67
68 // clip’ljÁ
69 //
70 // clip‘ŽŽ
71 // [num]
72 // num=1
73 // [dir]
74 // 1=c:\... etc.
75
76 BOOL addclip(char *from, char *to)
77 {
78 if(strlen(to)<=_ClipLen) return FALSE;
79 initclip(to);
80 int num =GetPrivateProfileInt(keydirnum, keydirnum, 0, clipdirfile);
81
82 num++;
83 char buf[10];
84 wsprintf(buf, "%d", num);
85 WritePrivateProfileString(keydir, buf, from, clipdirfile);
86 WritePrivateProfileString(keydirnum, keydirnum, buf, clipdirfile);
87 return TRUE;
88 }
89
90
91 void openClip(char *dir)
92 {
93 initclip(dir);
94 //GetPrivateProfileString(keydir, "", "", buffer, MAX_PATH, clipdirfile);
95
96 return;
97 }
98
99 void Exchange(dirw &ldir, dirw &rdir)
100 {
101 /*
102 char buf[1000];
103 ldir.GetCurrentDirectory(1000,buf);
104 ldir.SetCurrentDirectory(rdir.cd());
105 rdir.SetCurrentDirectory(buf);
106 */
107 HWND ledit=ldir.getEdit();
108 HWND llist=ldir.getList();
109 HWND redit=rdir.getEdit();
110 HWND rlist=rdir.getList();
111 dirw dir=ldir;
112
113 ldir =rdir;
114 rdir =dir;
115
116 ldir.setList(llist);
117 rdir.setList(rlist);
118 ldir.setEdit(ledit);
119 rdir.setEdit(redit);
120 }
121
122 void dirw::savedir()
123 {
124 savehisdir(lr, dir);
125 };
126
127 void dirw::savedir(char* path)
128 {
129 savehisdir(lr, path);
130 };
131
132
133 int dirw::getClipMax()
134 {
135 if( !hisf) clipmax =GetPrivateProfileInt(keydirnum, keydirnum, 0, clipdirfile);
136 else
137 {
138 if(hisLf) clipmax =gethismax(tab_l);
139 else clipmax =gethismax(tab_r);
140 }
141 return clipmax;
142 }
143
144 void getclipstr(char *key, char *ti, char *ans, char *file)
145 {
146 GetPrivateProfileString(key, ti, "", ans, MAX_PATH, file);
147 }
148
149
150 extern char hisldirfile[];
151 extern char hisrdirfile[];
152 extern char keyhis[];
153
154 char *dirw::getClip(int num)
155 {
156 static char buf[10], ans[MAX_PATH];
157 wsprintf(buf, "%d", num);
158 if(!hisf) {
159 getclipstr(keydir, buf, ans, clipdirfile);
160 //Mes(ans);
161 }
162 else{
163 if(hisRf) {
164 getclipstr(keyhis, buf, ans, hisrdirfile);
165 }
166 if(hisLf) {
167 getclipstr(keyhis, buf, ans, hisldirfile);
168 }
169 }
170 return ans;
171 }
172
173
174 char *getpath(char *dir)
175 {
176 if(!exist(dir)) return dir;
177 char path[MAX_PATH];
178 wsprintf(path,"%s",dir);
179 char *p=strrchr(path,'\\');
180 if(p!=NULL) *p=0;
181 return path;
182 }
183
184 // “ÁŽęiclip:,his:,mouse:,main:jƒ`ƒFƒbƒN‚ŕ‚ą‚ą‚Ĺ
185
186 char *dirw::SetCurrentDirectory(char *d)
187 {
188 //
189 BOOL f=FALSE;
190 hisf =FALSE;
191 if( isclip() || ishis() ||ismouse() ||ismain() )
192 {
193 if( strcmp(d,".")==0 ) return dir;
194 if( strcmp(d,"..")==0 )
195 {
196 wsprintf(dir, _MAIN_FOLDER);
197 return dir;
198 }
199 }
200
201 if(strcmp(dir,d)==0 && strlen(d)>0) f=TRUE;
202 if( ::ismouse(d) )
203 {
204 wsprintf(dir, d);
205 space=0;
206 total=0;
207 savedir();
208 return dir;
209 }
210 if( ::isclip(d) )
211 {
212 wsprintf(dir, d);
213 space=0;
214 total=0;
215 openClip(dir);
216 savedir();
217 return dir;
218 }
219 if( ::ishis(d) )
220 {
221 hisf =TRUE;
222 if(strncmp("his:R",d,5)==0 || strncmp("his:r",d,5)==0)
223 {
224 hisRf =TRUE;
225 wsprintf(dir, "his:R");
226 }
227 else
228 {
229 hisLf =TRUE;
230 wsprintf(dir, "his:L");
231 }
232 space=0;
233 total=0;
234 savedir();
235 return dir;
236 }
237 if( ::ismain(d) )
238 {
239 mainf =TRUE;
240 wsprintf(dir, d);
241 space=0;
242 total=0;
243 savedir();
244 return dir;
245 }
246
247 if( strncmp(d,"..",2)==0 && strlen(dir)==3)
248 if( dir[1]==':' )
249 {
250 wsprintf(dir, _MAIN_FOLDER);
251 return dir;
252 };
253 ::SetCurrentDirectory(dir);
254 ::SetCurrentDirectory(getpath(d));
255 ::GetCurrentDirectory(1000,dir);
256 //Mes(dir);
257 setDirHis(dir);
258 wsprintf(drive,"%s",dir);
259 if(!f && strlen(d)>0) savedir();
260 char *p =strchr( drive,'\\' );
261 if (p !=NULL ) if(strlen(p) >1 ) p[1]=0;
262 int i=GetDiskFreeSpaceEx( drive, &FreeBytesAv,
263 &Bytes,
264 &FreeBytes);
265 // (double)FreeAvBytes.u.HighPart*4294967296.0 + (double)FreeAvBytes.u.LowPart
266 if(i)
267 {
268 space =((double)(FreeBytesAv.u.LowPart)+
269 (double)FreeBytesAv.u.HighPart*4294967296.0)/1024/1024;
270 total =((double)(Bytes.u.LowPart)+
271 (double)Bytes.u.HighPart*4294967296.0)/1024/1024;
272 }
273 //space =(double)NumberOfFreeClusters *SectorsPerCluster *BytesPerSector/1024/1024;
274 else {space =0;total =0;};
275 return dir;
276 };
277
278 void dirw::hisback()
279 {
280 hispos(-1);
281 setDir(dirhis);
282 cd(dir);
283 };
284
285 void dirw::hisnext()
286 {
287 hispos(1);
288 setDir(dirhis);
289 cd(dir);
290 };
291 // reload‚Č‚ľ
292
293 void dirw::hisBackSee()
294 {
295 hispos(-1);
296 };
297
298 void dirw::hisNextSee()
299 {
300 hispos(1);
301 };
302
303 void dirw::hispos(int i)
304 {
305 loadhisdir(lr, dirhis, i);
306 //setDir(dirhis);
307 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision
svn:mime-type text/plain

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26