source: dev/ProjectEditor/FileOperation.cpp@ 60

Last change on this file since 60 was 24, checked in by dai_9181, 18 years ago

保存されていないドキュメントのタブに(*)をつける機能に対応。
MDITEXTEDITINFOをCMdiTextEditに変更。今後、オブジェクト指向化を進める。

File size: 15.6 KB
RevLine 
[3]1#include "Common.h"
2
3void MakeUserSettingDir(void){
4 char temporary[MAX_PATH];
5 sprintf(temporary,"%sUserSetting",pj_editor_Dir);
6
7 HANDLE hFind;
8 WIN32_FIND_DATA wfd;
9 hFind=FindFirstFile(temporary,&wfd);
10 if(hFind==INVALID_HANDLE_VALUE){
11 //UserSettingディレクトリを作成
12 if(!CreateDirectory(temporary,NULL)){
13 MessageBox(hOwner,"UserSettingディレクトリの作成に失敗",APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
14 return;
15 }
16 }
17}
18
19char *ReadBuffer(char *path){
20 extern HANDLE hHeap;
21 int i;
22 DWORD dw;
23 char *buffer,temporary[MAX_PATH];
24 HANDLE hFile;
25
26 hFile=CreateFile(path,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
27 if(hFile==INVALID_HANDLE_VALUE){
28 //"\"%s\" ファイルの読み込みに失敗しました。"
29 sprintf(temporary,STRING_ERROR_CANT_FILEOPEN,path);
30 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
31
32 return 0;
33 }
34 i=GetFileSize(hFile,0);
35 buffer=(char *)HeapAlloc(hHeap,0,i+1);
36 ReadFile(hFile,buffer,i,&dw,0);
37 buffer[dw]=0;
38 CloseHandle(hFile);
39 return buffer;
40}
41char *ReadBuffer_NonErrMsg(char *path){
42 extern HANDLE hHeap;
43 int i;
44 DWORD dw;
45 char *buffer;
46 HANDLE hFile;
47
48 hFile=CreateFile(path,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
49 if(hFile==INVALID_HANDLE_VALUE) return 0;
50 i=GetFileSize(hFile,0);
51 buffer=(char *)HeapAlloc(hHeap,0,i+1);
52 ReadFile(hFile,buffer,i,&dw,0);
53 buffer[dw]=0;
54 CloseHandle(hFile);
55 return buffer;
56}
57_int8 WriteBuffer(char *path,char *buffer,int length){
58 HANDLE hFile;
59 DWORD dw;
60 hFile=CreateFile(path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
61 if(hFile==INVALID_HANDLE_VALUE){
62 char temporary[MAX_PATH];
63
64 //"\"%s\" ファイルへの書き込みに失敗しました。"
65 sprintf(temporary,STRING_ERROR_CANT_FILESAVE,path);
66 MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
67 return 0;
68 }
69 if(length) WriteFile(hFile,buffer,length,&dw,NULL);
70 CloseHandle(hFile);
71 return 1;
72}
73_int8 WriteBuffer_NonErrMsg(char *path,char *buffer,int length){
74 extern HWND hOwnerEditor;
75 HANDLE hFile;
76 DWORD dw;
77 hFile=CreateFile(path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
78 if(hFile==INVALID_HANDLE_VALUE){
79 return 0;
80 }
81 if(length) WriteFile(hFile,buffer,length,&dw,NULL);
82 CloseHandle(hFile);
83 return 1;
84}
85void GetRelationalPath(char *path,char *dir){
86 //相対パスを取得
87 int i,i2,i3,i4,i5;
88 char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH],temp4[MAX_PATH];
89
90 //ドライブ名をチェック
91 _splitpath(path,temporary,0,0,0);
92 _splitpath(dir,temp2,0,0,0);
93 if(lstrcmpi(temporary,temp2)!=0) return;
94
95 _splitpath(path,0,temporary,0,0);
96 _splitpath(dir,0,temp2,0,0);
97 i=1;i2=1;
98 while(1){
99 i4=i;
100 if(temporary[i-1]=='\\'&&temporary[i]){ //path側
101 for(i3=0;;i++,i3++){
102 if(temporary[i]=='\\'){
103 temp3[i3]=0;
104 i++;
105 break;
106 }
107 temp3[i3]=temporary[i];
108 }
109 }
110 else temp3[0]=0;
111
112 i5=i2;
113 if(temp2[i2-1]=='\\'&&temp2[i2]){ //dir側
114 for(i3=0;;i2++,i3++){
115 if(temp2[i2]=='\\'){
116 temp4[i3]=0;
117 i2++;
118 break;
119 }
120 temp4[i3]=temp2[i2];
121 }
122 }
123 else temp4[0]=0;
124
125 if(temp3[0]=='\0'&&temp4[0]=='\0') break;
126
127 if(lstrcmpi(temp3,temp4)!=0){
128 for(i3=0;;i5++){
129 if(temp2[i5]=='\0') break;
130 if(temp2[i5]=='\\') i3++;
131 }
132 temp3[0]=0;
133 for(i2=0;i2<i3;i2++) lstrcat(temp3,"..\\");
134 lstrcat(temp3,temporary+i4);
135 break;
136 }
137 }
138 _splitpath(path,0,0,temporary,temp2);
139 lstrcat(temp3,temporary);
140 lstrcat(temp3,temp2);
141 lstrcpy(path,temp3);
142}
143void GetFullPath(char *path,char *dir){
144 int i,i2,i3,i4;
145 char temporary[MAX_PATH];
146
147 if(strstr(path,":")||strstr(path,"\\\\")) return;
148
149 i=0;i2=0;
150 while(1){
151 if(path[i]=='.'&&path[i+1]=='\\') i+=2;
152 if(path[i]=='.'&&path[i+1]=='.'&&path[i+2]=='\\'){
153 i2++;
154 i+=3;
155 }
156 else break;
157 }
158
159 i3=lstrlen(dir);i4=0;
160 while(i4<i2){
161 for(i3--;;i3--){
162 if(dir[i3-1]=='\\'){
163 i4++;
164 break;
165 }
166 }
167 }
168 memcpy(temporary,dir,i3);
169 temporary[i3]=0;
170 lstrcat(temporary,path+i);
171 lstrcpy(path,temporary);
172}
173
[22]174void RemoveDirectoryStrong(const char *dir_path){
[3]175 HANDLE hFind;
176 WIN32_FIND_DATA wfd;
177 char temporary[MAX_PATH];
178 sprintf(temporary,"%s*",dir_path);
179
180 hFind=FindFirstFile(temporary,&wfd);
181 if(hFind!=INVALID_HANDLE_VALUE){
182 do{
183 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
184 if(!(lstrcmp(wfd.cFileName,".")==0||lstrcmp(wfd.cFileName,"..")==0)){
185 //ディレクトリのとき
186 sprintf(temporary,"%s%s\\",dir_path,wfd.cFileName);
187 RemoveDirectoryStrong(temporary);
188 }
189 }
190 else{
191 //ファイルのとき
192 sprintf(temporary,"%s%s",dir_path,wfd.cFileName);
193
194 DeleteFile(temporary);
195 }
196 }while(FindNextFile(hFind,&wfd));
197 }
198
199 RemoveDirectory(dir_path);
200}
201
202BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,_int8 IsOpen){
203 OPENFILENAME ofstr;
204 filename[0]=0;
205 ofstr.lStructSize=sizeof(OPENFILENAME);
206 ofstr.hwndOwner=hwnd;
207 ofstr.hInstance=0;
208 ofstr.lpstrFilter=Filter;
209 ofstr.lpstrCustomFilter=NULL;
210 ofstr.nMaxCustFilter=0;
211 ofstr.nFilterIndex=1;
212 ofstr.lpstrFile=filename;
213 ofstr.nMaxFile=MAX_PATH;
214 ofstr.lpstrFileTitle=NULL;
215 ofstr.nMaxFileTitle=0;
216 ofstr.lpstrInitialDir=pobj_nv->DefSaveDir;
217 ofstr.lpstrTitle=Title;
218 ofstr.Flags=OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
219 ofstr.nFileOffset=0;
220 ofstr.nFileExtension=0;
221 ofstr.lpstrDefExt="*";
222 ofstr.lCustData=NULL;
223 ofstr.lpfnHook=NULL;
224 ofstr.lpTemplateName=NULL;
225 if(IsOpen){
226 if(!GetOpenFileName(&ofstr)) return FALSE;
227 }
228 else{
229 if(!GetSaveFileName(&ofstr)) return FALSE;
230 }
231
232 //次回の初期ディレクトリをセット
233 char temporary[MAX_PATH];
234 _splitpath(filename,pobj_nv->DefSaveDir,temporary,NULL,NULL);
235 lstrcat(pobj_nv->DefSaveDir,temporary);
236
237 return TRUE;
238}
239BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle){
240 BROWSEINFO BrowseInfo;
241 LPITEMIDLIST pidlBrowse;
242 LPMALLOC g_pMalloc;
243 char temporary[MAX_PATH];
244
245 BrowseInfo.hwndOwner=hWnd;
246 BrowseInfo.pszDisplayName=temporary;
247 BrowseInfo.pidlRoot=NULL;
248 BrowseInfo.lpszTitle=OpenFolderTitle;
249 BrowseInfo.ulFlags=BIF_RETURNONLYFSDIRS;
250 BrowseInfo.lpfn=NULL;
251 BrowseInfo.lParam=(LPARAM)0;
252 BrowseInfo.iImage=0;
253 pidlBrowse=SHBrowseForFolder(&BrowseInfo);
254 if(pidlBrowse){
255 if(SHGetMalloc(&g_pMalloc)!=0) return 0;
256 SHGetPathFromIDList(pidlBrowse,folder);
257 g_pMalloc->Free(pidlBrowse);
258 g_pMalloc->Release();
259 return 1;
260 }
261 return 0;
262}
263
264int GetFileExtension(char *path){
265 char temporary[MAX_PATH];
266 _splitpath(path,0,0,0,temporary);
267
268 if(lstrcmpi(temporary,".bas")==0||
269 lstrcmpi(temporary,".ab")==0||
270 lstrcmpi(temporary,".abp")==0) return FT_BASICPROGRAM;
271 if(lstrcmpi(temporary,".sbp")==0) return FT_SUBPROGRAM;
272 if(lstrcmpi(temporary,".txt")==0) return FT_TEXT;
273 if(lstrcmpi(temporary,".pj")==0) return FT_PROJECT;
274 if(lstrcmpi(temporary,".ico")==0) return FT_ICON;
275
276 if(lstrcmpi(temporary,".html")==0||
277 lstrcmpi(temporary,".htm")==0||
278 lstrcmpi(temporary,".tpl")==0||
279 lstrcmpi(temporary,".php")==0)
280 return FT_HTML;
281
282 return FT_OTHER;
283}
284HWND OpenFileWithExtension(char *OpenFileName){
285 int i;
286 _int8 DocumentType;
287
288 i=GetFileExtension(OpenFileName);
289
290#ifndef THETEXT
291 if(i==FT_PROJECT){
292 //「最近使ったプロジェクト」に追加
293 pobj_nv->pobj_ProjectHistory->insert(OpenFileName);
294
295 OpenProject(OpenFileName);
296 return 0;
297 }
298#endif
299
300 //「最近使ったファイル」に追加
301 pobj_nv->pobj_History->insert(OpenFileName);
302
303 if(i==FT_ICON){
304 NewIconEditWindow(OpenFileName);
305 return 0;
306 }
307 else if(i==FT_BASICPROGRAM||i==FT_SUBPROGRAM){
308 DocumentType=WNDTYPE_BASIC;
309
310#ifdef THETEXT
311 DocumentType=WNDTYPE_TEXT;
312#endif
313 }
314 else if(i==FT_HTML) DocumentType=WNDTYPE_HTML;
315 else DocumentType=WNDTYPE_TEXT;
316
317 COLORREF TabColor;
318 TabColor=pobj_nv->pobj_ExtLink->GetTabColorFromFilePath(OpenFileName);
319
320 return NewTextEditWindow(OpenFileName,DocumentType,TabColor);
321}
322BOOL SaveDocument(HWND hChild,char *SaveFileName){ //ウィンドウからバッファを読み取り、ファイルに保存
323 extern LPSTR IconFileFilter;
324 extern HWND hClient,hDocCombo;
325 extern MDIINFO MdiInfo[MAX_WNDNUM];
326 int WndNum,i2;
327 char temporary[MAX_PATH],str[MAX_PATH],str2[32];
328 HANDLE fh;
329 DWORD dummy;
330
331 WndNum=GetWndNum(hChild);
332
333 char szOldTitle[MAX_PATH];
334 lstrcpy(szOldTitle,MdiInfo[WndNum].title);
335
336 if(MdiInfo[WndNum].DocType==WNDTYPE_RAD||MdiInfo[WndNum].DocType==WNDTYPE_MENU){
337 ////////////////////////////////////
338 // RADツール及びメニューエディタ
339 ////////////////////////////////////
340
341 extern PROJECTINFO ProjectInfo;
342 if(ProjectInfo.ModifyOfMaterial){
343 sprintf(temporary,"%s%s.wnd",ProjectInfo.dir,ProjectInfo.name);
344 SaveWindowFile(temporary,ProjectInfo.pWindowInfo,ProjectInfo.NumberOfWindows);
345
346 //.wbpファイルを生成
347 SaveWindowProgram();
348 }
349 }
350 else if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
351 //////////////////////////
352 // テキストドキュメント
353 //////////////////////////
354
355 if(SaveFileName){
356 lstrcpy(temporary,SaveFileName);
357 if((fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))==INVALID_HANDLE_VALUE){
358 sprintf(str,STRING_FILE_OVERWRIDE,temporary);
359 if(MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNO|MB_ICONINFORMATION)==IDNO){
360 CloseHandle(fh);
361 return 0;
362 }
363 }
364 CloseHandle(fh);
365
366 //ドキュメント セレクト コンボボックスから消去
367 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
368 SendMessage(hDocCombo,CB_DELETESTRING,i2,0);
369
370 //新しいパスをセット
371 GlobalFree(MdiInfo[WndNum].path);
372 MdiInfo[WndNum].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(temporary)+1);
373 lstrcpy(MdiInfo[WndNum].path,temporary);
374
375 //ドキュメント セレクト コンボボックスに挿入
376 _splitpath(temporary,NULL,NULL,str,str2);
377 lstrcat(str,str2);
378 GlobalFree(MdiInfo[WndNum].title);
379 MdiInfo[WndNum].title=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(str)+1);
380 lstrcpy(MdiInfo[WndNum].title,str);
381 SendMessage(hDocCombo,CB_ADDSTRING,0,(long)MdiInfo[WndNum].title);
382 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
383 SendMessage(hDocCombo,CB_SETCURSEL,i2,0);
384
385 //MDIウィンドウのタイトルを再設定
386 SetWindowText(hChild,MdiInfo[WndNum].title);
387 }
388 else{
389 if(MdiInfo[WndNum].path[0]=='\0'){
390 //"保存先のファイルを指定してください"
391get_file_path:
392
393 LPSTR ff;
394
395 extern LPSTR DefFileFilter;
396 extern LPSTR HtmlFileFilter;
397 extern LPSTR TextFileFilter;
398 if(MdiInfo[WndNum].DocType==WNDTYPE_BASIC)
399 ff=DefFileFilter;
400 else if(MdiInfo[WndNum].DocType==WNDTYPE_HTML)
401 ff=HtmlFileFilter;
402 else if(MdiInfo[WndNum].DocType==WNDTYPE_TEXT)
403 ff=TextFileFilter;
404
405 if(!GetFilePathDialog(hOwner,temporary,ff,STRING_FILESAVETITLE_DEFAULT,FALSE)) return 0;
406 SaveDocument(hChild,temporary);
407 return 1;
408 }
409 lstrcpy(temporary,MdiInfo[WndNum].path);
410 }
411
[22]412 if(!IsExistFile(temporary)){
[3]413 //保存先ファイルが存在しないとき
414 char temp2[MAX_PATH];
415
416 //初期ディレクトリをセット
417 _splitpath(temporary,pobj_nv->DefSaveDir,temp2,NULL,NULL);
418 lstrcat(pobj_nv->DefSaveDir,temp2);
419
420 goto get_file_path;
421 }
422
423 //文字コードを復元
424 char *pBuf;
[24]425 pBuf=nkf.RestoreBuffer(MdiInfo[WndNum].pMdiTextEdit->buffer,MdiInfo[WndNum].pMdiTextEdit->iCharCode);
[3]426
427 //改行コードを復元
[24]428 if(MdiInfo[WndNum].pMdiTextEdit->iLfCode==LFCODE_LF) nkf.ToLF(pBuf);
429 else if(MdiInfo[WndNum].pMdiTextEdit->iLfCode==LFCODE_CR) nkf.ToCR(pBuf);
[3]430
431
432 ////////////////////////
433 // 保存
434 ////////////////////////
435
436 fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
437 if(fh==INVALID_HANDLE_VALUE){
438 sprintf(str,STRING_ERROR_CANT_FILESAVE,temporary);
439 MessageBox(hOwner,str,STRING_ERROR,MB_OK|MB_ICONSTOP);
440 return 0;
441 }
442 WriteFile(fh,pBuf,lstrlen(pBuf),&dummy,NULL);
443 CloseHandle(fh);
444
445
446 HeapDefaultFree(pBuf);
447
[24]448 //変更フラグをオフにする
449 MdiInfo[WndNum].pMdiTextEdit->UnModify();
[3]450 }
451 else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
452 ///////////////////
453 // ICON
454 ///////////////////
455
456 if(SaveFileName){
457 lstrcpy(temporary,SaveFileName);
458 if((fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))==INVALID_HANDLE_VALUE){
459 sprintf(str,STRING_FILE_OVERWRIDE,temporary);
460 if(MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNO|MB_ICONINFORMATION)==IDNO){
461 CloseHandle(fh);
462 return 0;
463 }
464 }
465 CloseHandle(fh);
466 GlobalFree(MdiInfo[WndNum].path);
467 MdiInfo[WndNum].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(temporary)+1);
468 lstrcpy(MdiInfo[WndNum].path,temporary);
469 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
470 SendMessage(hDocCombo,CB_DELETESTRING,i2,0);
471 _splitpath(temporary,NULL,NULL,str,str2);
472 lstrcat(str,str2);
473 lstrcpy(MdiInfo[WndNum].title,str);
474 SendMessage(hDocCombo,CB_ADDSTRING,0,(long)MdiInfo[WndNum].title);
475 i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
476 SendMessage(hDocCombo,CB_SETCURSEL,i2,0);
477 SetWindowText(hChild,MdiInfo[WndNum].title);
478 }
479 else{
480 if(MdiInfo[WndNum].path[0]=='\0'){
481 //"保存先のファイルを指定してください"
482 if(!GetFilePathDialog(hOwner,temporary,IconFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return 0;
483 SaveDocument(hChild,temporary);
484 return 1;
485 }
486 lstrcpy(temporary,MdiInfo[WndNum].path);
487 }
488 SaveIconFile(temporary,hChild);
489
490 MdiInfo[WndNum].MdiIconEditInfo->bModify=0;
491 }
492
493
494 //タブコントロールを再設定
495 if(pobj_nv->bSaveTabToHead){
496 COLORREF color;
497 color=pobj_MainTab->GetItemColor(szOldTitle);
[24]498 pobj_MainTab->DeleteItem( szOldTitle, false );
499 pobj_MainTab->InsertItem( MdiInfo[WndNum].title, false, color );
[3]500 }
501 else{
[24]502 pobj_MainTab->RenameItem( szOldTitle, MdiInfo[WndNum].title );
[3]503 }
504
505 //「最近使ったファイル」を更新
506 pobj_nv->pobj_History->insert(MdiInfo[WndNum].path);
507
508 return 1;
509}
510BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath){
511 HANDLE hFind;
512 WIN32_FIND_DATA wfd;
513 int i;
514 char dummy[MAX_PATH];
515 for(i=0;i<MAX_PATH;i++){
516 LongPath[i]=ShortPath[i];
517 if((ShortPath[i-1]==':'&&ShortPath[i]=='\\')||(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\')){
518 LongPath[i+1]=0;
519 break;
520 }
521 }
522 if(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\'){
523 for(i++;i<MAX_PATH;i++){
524 if(IsDBCSLeadByte(ShortPath[i])){
525 i++;
526 continue;
527 }
528 LongPath[i]=ShortPath[i];
529 if(ShortPath[i]=='\\'){
530 LongPath[i+1]=0;
531 break;
532 }
533 }
534 for(i++;i<MAX_PATH;i++){
535 if(IsDBCSLeadByte(ShortPath[i])){
536 i++;
537 continue;
538 }
539 LongPath[i]=ShortPath[i];
540 if(ShortPath[i]=='\\'){
541 LongPath[i+1]=0;
542 break;
543 }
544 }
545 }
546 for(i++;i<MAX_PATH;i++){
547 if(IsDBCSLeadByte(ShortPath[i])){
548 i++;
549 continue;
550 }
551 if(ShortPath[i]=='\\'||ShortPath[i]=='\0'){
552 strncpy(dummy,ShortPath,i);
553 dummy[i]=0;
554 if((hFind=FindFirstFile(dummy,&wfd))!=INVALID_HANDLE_VALUE) FindClose(hFind);
555 lstrcat(LongPath,wfd.cFileName);
556
557 if(ShortPath[i]=='\0') break;
558 lstrcat(LongPath,"\\");
559
560 if(ShortPath[i]=='\\'&&ShortPath[i+1]=='\0'){
561 break;
562 }
563 }
564 }
565 return 1;
566}
567
[22]568bool IsExistFile( const char *FilePath ){
[3]569 WIN32_FIND_DATA wfd;
570 HANDLE hFind;
571
[22]572 hFind = FindFirstFile(FilePath,&wfd);
573 if( hFind == INVALID_HANDLE_VALUE ){
574 return false;
[3]575 }
[22]576 FindClose( hFind );
[3]577
[22]578 return true;
[3]579}
[22]580
581bool IsExistDirectory( const char *DirPath ){
582 WIN32_FIND_DATA wfd;
583 HANDLE hFind;
584
585 hFind = FindFirstFile(DirPath,&wfd);
586 if( hFind == INVALID_HANDLE_VALUE ){
587 //存在しない
588 return false;
589 }
590 FindClose( hFind );
591
592 if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ){
593 //ディレクトリの場合
594 return true;
595 }
596
597 //存在しない
598 return false;
599}
Note: See TracBrowser for help on using the repository browser.