source: dev/trunk/ab5.0/abdev/ProjectEditor/FileOperation.cpp@ 479

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

構成管理を変更中・・・(いったんコミット)

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