Rev 442 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 442 | Rev 444 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | #include "str.h" |
30 | #include "str.h" |
31 | #include "dbg.h" |
31 | #include "dbg.h" |
32 | #include "compat_string.h" |
32 | #include "compat_string.h" |
33 | 33 | ||
34 | 34 | ||
35 | Boolean fileHasExtension(StandardFileReply* sfr, const char* extension) { |
35 | Boolean fileHasExtension(StandardFileReply* sfr, const TCHAR* extension) { |
36 | char name[MAX_PATH + 1]; |
- | |
37 | return sfr->nFileExtension && !strcasecmp(myp2cstrcpy(name, sfr->sfFile.name) + sfr->nFileExtension - 1, extension); |
36 | return sfr->nFileExtension && !xstrcasecmp(sfr->sfFile.szName + sfr->nFileExtension - 1, extension); |
38 | } |
37 | } |
39 | 38 | ||
40 | Boolean choosefiletypes(StringPtr prompt,StandardFileReply *sfr,NavReplyRecord *reply, |
39 | Boolean choosefiletypes(PString prompt,StandardFileReply *sfr,NavReplyRecord *reply, |
41 | OSType types[],int ntypes,const char *lpstrFilter,HWND hwndOwner){ |
40 | OSType types[],int ntypes,const TCHAR *lpstrFilter,HWND hwndOwner){ |
42 | UNREFERENCED_PARAMETER(ntypes); |
41 | UNREFERENCED_PARAMETER(ntypes); |
43 | return choosefile(prompt,sfr,reply,types[0],lpstrFilter,hwndOwner); |
42 | return choosefile(prompt,sfr,reply,types[0],lpstrFilter,hwndOwner); |
44 | } |
43 | } |
45 | 44 | ||
46 | Boolean choosefile(StringPtr prompt,StandardFileReply *sfr,NavReplyRecord *reply,OSType type,const char *lpstrFilter,HWND hwndOwner){ |
45 | Boolean choosefile(PString prompt,StandardFileReply *sfr,NavReplyRecord *reply,OSType type,const TCHAR *lpstrFilter,HWND hwndOwner){ |
47 | OPENFILENAME ofn; |
46 | OPENFILENAME ofn; |
48 | char file[MAX_PATH]={0}; |
47 | TCHAR file[MAX_PATH+1]={0}; |
49 | char title[0x100]; |
- | |
50 | 48 | ||
51 | UNREFERENCED_PARAMETER(type); |
49 | UNREFERENCED_PARAMETER(type); |
52 | UNREFERENCED_PARAMETER(reply); |
50 | UNREFERENCED_PARAMETER(reply); |
53 | 51 | ||
54 | ZeroMemory(&ofn, sizeof(ofn)); |
52 | ZeroMemory(&ofn, sizeof(ofn)); |
Line 57... | Line 55... | ||
57 | ofn.hwndOwner = hwndOwner; |
55 | ofn.hwndOwner = hwndOwner; |
58 | ofn.lpstrFilter = lpstrFilter ; |
56 | ofn.lpstrFilter = lpstrFilter ; |
59 | // ofn.nFilterIndex = 1; |
57 | // ofn.nFilterIndex = 1; |
60 | ofn.lpstrFile = file; |
58 | ofn.lpstrFile = file; |
61 | ofn.nMaxFile = MAX_PATH; |
59 | ofn.nMaxFile = MAX_PATH; |
62 | ofn.lpstrTitle = myp2cstrcpy(title,prompt); |
60 | ofn.lpstrTitle = prompt; |
63 | ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; |
61 | ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; |
64 | // ofn.lpstrDefExt = lpstrDefExt; |
62 | // ofn.lpstrDefExt = lpstrDefExt; |
65 | 63 | ||
66 | if(GetOpenFileName(&ofn)){ |
64 | if(GetOpenFileName(&ofn)){ |
67 | myc2pstrcpy(sfr->sfFile.name,file); |
65 | xstrcpy(sfr->sfFile.szName, file); |
68 | sfr->nFileExtension = ofn.nFileExtension; |
66 | sfr->nFileExtension = ofn.nFileExtension; |
69 | return sfr->sfGood = true; |
67 | return sfr->sfGood = true; |
70 | }else{ |
68 | }else{ |
71 | #ifdef DEBUG |
69 | #ifdef DEBUG |
72 | char s[100]; |
70 | char s[100]; |
Line 76... | Line 74... | ||
76 | } |
74 | } |
77 | 75 | ||
78 | return sfr->sfGood = false; |
76 | return sfr->sfGood = false; |
79 | } |
77 | } |
80 | 78 | ||
81 | Boolean putfile(StringPtr prompt,StringPtr fname,OSType fileType,OSType fileCreator, |
79 | Boolean putfile(PString prompt, PString fname,OSType fileType,OSType fileCreator, |
82 | NavReplyRecord *reply,StandardFileReply *sfr, |
80 | NavReplyRecord *reply,StandardFileReply *sfr, |
83 | const char *lpstrDefExt,const char *lpstrFilter,int nFilterIndex, |
81 | const TCHAR*lpstrDefExt,const TCHAR *lpstrFilter,int nFilterIndex, |
84 | HWND hwndOwner){ |
82 | HWND hwndOwner){ |
85 | OPENFILENAME ofn; |
83 | OPENFILENAME ofn; |
86 | char file[MAX_PATH]; |
84 | TCHAR file[MAX_PATH+1]={0}; |
87 | char title[0x100]; |
- | |
88 | 85 | ||
89 | UNREFERENCED_PARAMETER(fileCreator); |
86 | UNREFERENCED_PARAMETER(fileCreator); |
90 | UNREFERENCED_PARAMETER(reply); |
87 | UNREFERENCED_PARAMETER(reply); |
91 | UNREFERENCED_PARAMETER(fileType); |
88 | UNREFERENCED_PARAMETER(fileType); |
92 | 89 | ||
93 | ZeroMemory(&ofn, sizeof(ofn)); |
90 | ZeroMemory(&ofn, sizeof(ofn)); |
94 | 91 | ||
- | 92 | xstrcpy(file, (LPTSTR)fname); |
|
- | 93 | ||
95 | ofn.lStructSize = sizeof(ofn); |
94 | ofn.lStructSize = sizeof(ofn); |
96 | ofn.hwndOwner = hwndOwner; |
95 | ofn.hwndOwner = hwndOwner; |
97 | ofn.lpstrFilter = lpstrFilter; |
96 | ofn.lpstrFilter = lpstrFilter; |
98 | ofn.nFilterIndex = nFilterIndex; |
97 | ofn.nFilterIndex = nFilterIndex; |
99 | ofn.lpstrFile = myp2cstrcpy(file,fname); |
98 | ofn.lpstrFile = file; |
100 | ofn.nMaxFile = MAX_PATH; |
99 | ofn.nMaxFile = MAX_PATH; |
101 | ofn.lpstrTitle = myp2cstrcpy(title,prompt); |
100 | ofn.lpstrTitle = prompt; |
102 | ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; |
101 | ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; |
103 | ofn.lpstrDefExt = lpstrDefExt; |
102 | ofn.lpstrDefExt = lpstrDefExt; |
104 | 103 | ||
105 | if(GetSaveFileName(&ofn)){ |
104 | if(GetSaveFileName(&ofn)){ |
106 | myc2pstrcpy(sfr->sfFile.name,file); |
105 | xstrcpy(sfr->sfFile.szName, file); |
107 | sfr->nFileExtension = ofn.nFileExtension; |
106 | sfr->nFileExtension = ofn.nFileExtension; |
108 | return sfr->sfGood = true; |
107 | return sfr->sfGood = true; |
109 | }else{ |
108 | }else{ |
110 | #ifdef DEBUG |
109 | #ifdef DEBUG |
111 | char s[100]; |
110 | char s[100]; |