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

Last change on this file since 619 was 619, checked in by dai_9181, 15 years ago

Projectクラスをリファクタリング中。

File size: 15.9 KB
Line 
1#include "stdafx.h"
2
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
21char *ReadBuffer( const std::string &path ){
22    extern HANDLE hHeap;
23    int i;
24    DWORD dw;
25    char *buffer,temporary[MAX_PATH];
26    HANDLE hFile;
27
28    hFile=CreateFile(path.c_str(),GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
29    if(hFile==INVALID_HANDLE_VALUE){
30        //"\"%s\" ファイルの読み込みに失敗しました。"
31        sprintf(temporary,STRING_ERROR_CANT_FILEOPEN,path.c_str());
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}
43char *ReadBuffer_NonErrMsg( const std::string &path ){
44    extern HANDLE hHeap;
45    int i;
46    DWORD dw;
47    char *buffer;
48    HANDLE hFile;
49
50    hFile=CreateFile(path.c_str(),GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
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}
59_int8 WriteBuffer(char *path,char *buffer,int length, bool isEnableError){
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
66        if( isEnableError ){
67            //"\"%s\" ファイルへの書き込みに失敗しました。"
68            sprintf(temporary,STRING_ERROR_CANT_FILESAVE,path);
69            MessageBox(hOwner,temporary,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
70        }
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){
78    return WriteBuffer( path, buffer, length, false );
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
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
177    HANDLE hFind;
178    WIN32_FIND_DATA wfd;
179    char temporary[MAX_PATH];
180    sprintf(temporary,"%s\\*",tempDirPath);
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                    //ディレクトリのとき
188                    sprintf(temporary,"%s\\%s\\",tempDirPath,wfd.cFileName);
189                    RemoveDirectoryStrong(temporary);
190                }
191            }
192            else{
193                //ファイルのとき
194                sprintf(temporary,"%s\\%s",tempDirPath,wfd.cFileName);
195
196                DeleteFile(temporary);
197            }
198        }while(FindNextFile(hFind,&wfd));
199
200        FindClose( hFind );
201    }
202
203    if( !RemoveDirectory(tempDirPath) ){
204        OutputDebugString( GetLastErrorString().c_str() );
205        OutputDebugString( "\r\n" );
206        OutputDebugString( "一時ディレクトリの削除に失敗\r\n" );
207    }
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        projectInfo.Open(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        if(projectInfo.ModifyOfMaterial){
350            sprintf(temporary,"%s%s.wnd",projectInfo.dir,projectInfo.GetName().c_str());
351            SaveWindowFile( temporary, projectInfo.windowInfos );
352
353            //.wbpファイルを生成
354            SaveWindowProgram();
355        }
356    }
357    else if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
358        //////////////////////////
359        // テキストドキュメント
360        //////////////////////////
361
362        if(SaveFileName){
363            lstrcpy(temporary,SaveFileName);
364            if((fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))==INVALID_HANDLE_VALUE){
365                sprintf(str,STRING_FILE_OVERWRIDE,temporary);
366                if(MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNO|MB_ICONINFORMATION)==IDNO){
367                    CloseHandle(fh);
368                    return 0;
369                }
370            }
371            CloseHandle(fh);
372
373            //ドキュメント セレクト コンボボックスから消去
374            i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
375            SendMessage(hDocCombo,CB_DELETESTRING,i2,0);
376
377            //新しいパスをセット
378            GlobalFree(MdiInfo[WndNum].path);
379            MdiInfo[WndNum].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(temporary)+1);
380            lstrcpy(MdiInfo[WndNum].path,temporary);
381
382            //ドキュメント セレクト コンボボックスに挿入
383            _splitpath(temporary,NULL,NULL,str,str2);
384            lstrcat(str,str2);
385            GlobalFree(MdiInfo[WndNum].title);
386            MdiInfo[WndNum].title=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(str)+1);
387            lstrcpy(MdiInfo[WndNum].title,str);
388            SendMessage(hDocCombo,CB_ADDSTRING,0,(long)MdiInfo[WndNum].title);
389            i2=SendMessage(hDocCombo,CB_FINDSTRINGEXACT,0,(long)MdiInfo[WndNum].title);
390            SendMessage(hDocCombo,CB_SETCURSEL,i2,0);
391
392            //MDIウィンドウのタイトルを再設定
393            SetWindowText(hChild,MdiInfo[WndNum].title);
394        }
395        else{
396            if(MdiInfo[WndNum].path[0]=='\0'){
397                //"保存先のファイルを指定してください"
398get_file_path:
399
400                LPSTR ff;
401
402                extern LPSTR DefFileFilter;
403                extern LPSTR HtmlFileFilter;
404                extern LPSTR TextFileFilter;
405                if(MdiInfo[WndNum].DocType==WNDTYPE_BASIC)
406                    ff=DefFileFilter;
407                else if(MdiInfo[WndNum].DocType==WNDTYPE_HTML)
408                    ff=HtmlFileFilter;
409                else if(MdiInfo[WndNum].DocType==WNDTYPE_TEXT)
410                    ff=TextFileFilter;
411
412                if(!GetFilePathDialog(hOwner,temporary,ff,STRING_FILESAVETITLE_DEFAULT,FALSE)) return 0;
413                SaveDocument(hChild,temporary);
414                return 1;
415            }
416            lstrcpy(temporary,MdiInfo[WndNum].path);
417        }
418
419        if(!IsExistFile(temporary)){
420            //保存先ファイルが存在しないとき
421            char temp2[MAX_PATH];
422
423            //初期ディレクトリをセット
424            _splitpath(temporary,pobj_nv->DefSaveDir,temp2,NULL,NULL);
425            lstrcat(pobj_nv->DefSaveDir,temp2);
426
427            goto get_file_path;
428        }
429
430        //文字コードを復元
431        char *pBuf;
432        pBuf=nkf.RestoreBuffer(MdiInfo[WndNum].pMdiTextEdit->buffer,MdiInfo[WndNum].pMdiTextEdit->iCharCode);
433
434        //改行コードを復元
435        if(MdiInfo[WndNum].pMdiTextEdit->iLfCode==LFCODE_LF) nkf.ToLF(pBuf);
436        else if(MdiInfo[WndNum].pMdiTextEdit->iLfCode==LFCODE_CR) nkf.ToCR(pBuf);
437
438
439        ////////////////////////
440        // 保存
441        ////////////////////////
442
443        fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
444        if(fh==INVALID_HANDLE_VALUE){
445            sprintf(str,STRING_ERROR_CANT_FILESAVE,temporary);
446            MessageBox(hOwner,str,STRING_ERROR,MB_OK|MB_ICONSTOP);
447            return 0;
448        }
449        WriteFile(fh,pBuf,lstrlen(pBuf),&dummy,NULL);
450        CloseHandle(fh);
451
452
453        HeapDefaultFree(pBuf);
454
455        //変更フラグをオフにする
456        MdiInfo[WndNum].pMdiTextEdit->UnModify();
457    }
458    else if(MdiInfo[WndNum].DocType==WNDTYPE_ICONEDIT){
459        ///////////////////
460        // ICON
461        ///////////////////
462
463        if(SaveFileName){
464            lstrcpy(temporary,SaveFileName);
465            if((fh=CreateFile(temporary,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))==INVALID_HANDLE_VALUE){
466                sprintf(str,STRING_FILE_OVERWRIDE,temporary);
467                if(MessageBox(hOwner,str,APPLICATION_NAME,MB_YESNO|MB_ICONINFORMATION)==IDNO){
468                    CloseHandle(fh);
469                    return 0;
470                }
471            }
472            CloseHandle(fh);
473            GlobalFree(MdiInfo[WndNum].path);
474            MdiInfo[WndNum].path=(char *)GlobalAlloc(GMEM_FIXED,lstrlen(temporary)+1);
475            lstrcpy(MdiInfo[WndNum].path,temporary);
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{
487            if(MdiInfo[WndNum].path[0]=='\0'){
488                //"保存先のファイルを指定してください"
489                if(!GetFilePathDialog(hOwner,temporary,IconFileFilter,STRING_FILESAVETITLE_DEFAULT,FALSE)) return 0;
490                SaveDocument(hChild,temporary);
491                return 1;
492            }
493            lstrcpy(temporary,MdiInfo[WndNum].path);
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);
505        pobj_MainTab->DeleteItem( szOldTitle, false );
506        pobj_MainTab->InsertItem( MdiInfo[WndNum].title, false, color );
507    }
508    else{
509        pobj_MainTab->RenameItem( szOldTitle, MdiInfo[WndNum].title );
510    }
511
512    //「最近使ったファイル」を更新
513    pobj_nv->pobj_History->insert(MdiInfo[WndNum].path);
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
575bool IsExistFile( const char *FilePath ){
576    WIN32_FIND_DATA wfd;
577    HANDLE hFind;
578
579    hFind = FindFirstFile(FilePath,&wfd);
580    if( hFind == INVALID_HANDLE_VALUE ){
581        return false;
582    }
583    FindClose( hFind );
584
585    return true;
586}
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.