source: trunk/dll/archive.c@ 1036

Last change on this file since 1036 was 907, checked in by Steven Levine, 18 years ago

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1
2/***********************************************************************
3
4 $Id: archive.c 907 2008-01-06 07:26:17Z stevenhl $
5
6 Archive create/update dialog procedure
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004, 2006 Steven H.Levine
10
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 28 Jun 06 SHL Drop obsoletes
13 17 Jul 06 SHL Use Runtime_Error
14 22 Mar 07 GKY Use QWL_USER
15 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
16
17***********************************************************************/
18
19#include <string.h>
20
21#define INCL_WIN
22#define INCL_DOS
23#define INCL_LONGLONG // dircnrs.h
24
25#include "fm3dlg.h"
26#include "fm3str.h"
27#include "strutil.h" // GetPString
28#include "errutil.h" // Runtime_Error
29#include "fm3dll.h"
30
31static PSZ pszSrcFile = __FILE__;
32
33MRESULT EXPENTRY ArchiveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
34{
35 DIRCNRDATA *arcdata = NULL;
36
37 switch (msg) {
38 case WM_INITDLG:
39 WinSetWindowPtr(hwnd, QWL_USER, mp2);
40 arcdata = (DIRCNRDATA *) mp2;
41 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETTEXTLIMIT,
42 MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
43 if (!arcdata->namecanchange) {
44 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETREADONLY,
45 MPFROM2SHORT(TRUE, 0), MPVOID);
46 WinEnableWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
47 WinShowWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
48 }
49 WinSendDlgItemMsg(hwnd, ARCH_COMMAND, EM_SETTEXTLIMIT,
50 MPFROM2SHORT(256, 0), MPVOID);
51 WinSendDlgItemMsg(hwnd, ARCH_MASKS, EM_SETTEXTLIMIT,
52 MPFROM2SHORT(256, 0), MPVOID);
53 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcdata->arcname);
54 if (arcdata->fmoving && arcdata->info->move) {
55 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->move);
56 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK,
57 MPFROM2SHORT(TRUE, 0), MPVOID);
58 }
59 else
60 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->create);
61 if (!arcdata->info->createrecurse)
62 WinEnableWindow(WinWindowFromID(hwnd, ARCH_RECURSE), FALSE);
63 if (!arcdata->info->move && !arcdata->info->movewdirs)
64 WinEnableWindow(WinWindowFromID(hwnd, ARCH_MOVE), FALSE);
65 if (!arcdata->info->createwdirs && !arcdata->info->movewdirs)
66 WinEnableWindow(WinWindowFromID(hwnd, ARCH_INCLPATH), FALSE);
67 *arcdata->command = 0;
68 PosOverOkay(hwnd);
69 break;
70
71 case WM_ADJUSTWINDOWPOS:
72 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
73 break;
74
75 case UM_SETDIR:
76 PaintRecessedWindow(WinWindowFromID(hwnd, ARCH_HELP), (HPS) 0, FALSE,
77 TRUE);
78 return 0;
79
80 case WM_CONTROL:
81 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
82 switch (SHORT1FROMMP(mp1)) {
83 case ARCH_ARCNAME:
84 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
85 WinSetDlgItemText(hwnd, ARCH_HELP,
86 GetPString(IDS_ARCDEFAULTHELPTEXT));
87 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
88 WinSetDlgItemText(hwnd, ARCH_HELP,
89 GetPString(IDS_ARCARCNAMEHELPTEXT));
90 break;
91
92 case ARCH_COMMAND:
93 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
94 WinSetDlgItemText(hwnd, ARCH_HELP,
95 GetPString(IDS_ARCDEFAULTHELPTEXT));
96 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
97 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCCMDHELPTEXT));
98 break;
99
100 case ARCH_MASKS:
101 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
102 WinSetDlgItemText(hwnd, ARCH_HELP,
103 GetPString(IDS_ARCDEFAULTHELPTEXT));
104 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
105 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCMASKHELPTEXT));
106
107 break;
108
109 case ARCH_INCLPATH:
110 case ARCH_RECURSE:
111 case ARCH_MOVE:
112 {
113 BOOL fRecurse = FALSE, fMove = FALSE, fInclDirs = FALSE;
114 CHAR *cmd;
115
116 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_QUERYCHECK,
117 MPVOID, MPVOID)) {
118 fRecurse = TRUE;
119 if (SHORT1FROMMP(mp1) == ARCH_RECURSE) {
120 if (arcdata->info->createrecurse && *arcdata->info->createrecurse) {
121 fMove = FALSE;
122 fInclDirs = FALSE;
123 WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_SETCHECK,
124 MPVOID, MPVOID);
125 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK, MPVOID, MPVOID);
126 }
127 else {
128 fRecurse = FALSE;
129 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK,
130 MPVOID, MPVOID);
131 }
132 }
133 }
134 else
135 fRecurse = FALSE;
136 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_QUERYCHECK,
137 MPVOID, MPVOID)) {
138 fMove = TRUE;
139 fRecurse = FALSE;
140 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
141 }
142 else
143 fMove = FALSE;
144 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_QUERYCHECK,
145 MPVOID, MPVOID)) {
146 fInclDirs = TRUE;
147 fRecurse = FALSE;
148 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
149 }
150 else
151 fInclDirs = FALSE;
152 cmd = NULL;
153 if (fMove) {
154 if (fInclDirs || fRecurse)
155 cmd = arcdata->info->movewdirs;
156 else
157 cmd = arcdata->info->move;
158 if (!cmd || !*cmd)
159 cmd = arcdata->info->move;
160 }
161 if (!cmd || !*cmd) {
162 if (fInclDirs) {
163 cmd = arcdata->info->createwdirs;
164 if (!cmd || !*cmd)
165 cmd = arcdata->info->createrecurse;
166 }
167 else if (fRecurse) {
168 cmd = arcdata->info->createrecurse;
169 if (!cmd || !*cmd)
170 cmd = arcdata->info->createwdirs;
171 }
172 if (!cmd || !*cmd)
173 cmd = arcdata->info->create;
174 }
175 if (cmd)
176 WinSetDlgItemText(hwnd, ARCH_COMMAND, cmd);
177 }
178 break;
179 }
180 return 0;
181
182 case WM_COMMAND:
183 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
184 if (!arcdata) {
185 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
186 return 0;
187 }
188 switch (SHORT1FROMMP(mp1)) {
189 case DID_CANCEL:
190 WinDismissDlg(hwnd, 0);
191 break;
192 case DID_OK:
193 {
194 CHAR s[CCHMAXPATH + 1];
195
196 *s = 0;
197 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
198 bstrip(s);
199 if (*s) {
200 if (DosQueryPathInfo(s,
201 FIL_QUERYFULLNAME,
202 arcdata->arcname, CCHMAXPATH))
203 strcpy(arcdata->arcname, s);
204 *s = 0;
205 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
206 if (*s) {
207 strcpy(arcdata->command, s);
208 *s = 0;
209 WinQueryDlgItemText(hwnd, ARCH_MASKS, 256, s);
210 *arcdata->mask.szMask = 0;
211 strcpy(arcdata->mask.szMask, s);
212 WinDismissDlg(hwnd, 1);
213 break;
214 }
215 }
216 }
217 DosBeep(50, 100);
218 break;
219
220 case IDM_HELP:
221 if (hwndHelp)
222 WinSendMsg(hwndHelp,
223 HM_DISPLAY_HELP,
224 MPFROM2SHORT(HELP_ARCHIVE, 0), MPFROMSHORT(HM_RESOURCEID));
225 break;
226
227 case ARCH_FIND:
228 if (arcdata->namecanchange) {
229
230 CHAR arcname[CCHMAXPATH], s[CCHMAXPATH], *p;
231
232 *s = 0;
233 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
234 bstrip(s);
235 if (DosQueryPathInfo(s, FIL_QUERYFULLNAME, arcname, CCHMAXPATH))
236 strcpy(arcname, s);
237 p = strrchr(arcname, '\\');
238 if (p) {
239 p++;
240 p = strrchr(arcname, '.');
241 }
242 if (!p && arcdata->info->ext && *arcdata->info->ext) {
243 strcat(arcname, "*.");
244 strcat(arcname, arcdata->info->ext);
245 }
246 if (export_filename(hwnd, arcname, FALSE))
247 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcname);
248 }
249 break;
250
251 case ARCH_SEE:
252 {
253 CHAR s[1001], *p;
254
255 *s = 0;
256 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
257 bstrip(s);
258 if (*s) {
259 p = strchr(s, ' ');
260 if (p)
261 *p = 0;
262 ExecOnList(hwnd, s, WINDOWED | SEPARATEKEEP | MAXIMIZED | PROMPT,
263 NULL, NULL, GetPString(IDS_ARCEXECHELPTEXT),
264 pszSrcFile, __LINE__);
265 }
266 else
267 DosBeep(50, 100);
268 }
269 break;
270 }
271 return 0;
272
273 case WM_CLOSE:
274 break;
275 }
276 return WinDefDlgProc(hwnd, msg, mp1, mp2);
277}
278
279#pragma alloc_text(FMARCHIVE,ArchiveDlgProc)
Note: See TracBrowser for help on using the repository browser.