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

Last change on this file since 625 was 625, checked in by dai_9181, 16 years ago

・WindowInfoクラスをリファクタリング
・MdiInfoを単純配列からvectorに変更した。

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