source: dev/trunk/abdev/ProjectEditor/FileOperation.cpp@ 244

Last change on this file since 244 was 99, checked in by dai_9181, 18 years ago

Namespaceステートメントのエスケープシーケンス化を行った。
[IDE]バックアップに失敗したときにエラーメッセージを出さないようにした。

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