source: dev/ProjectEditor/FileOperation.cpp@ 80

Last change on this file since 80 was 80, checked in by dai_9181, 17 years ago

TheText用のリソースを追加。
単語単位での検索を可能にした。

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