| [2] | 1 | #define INCL_DOS | 
|---|
|  | 2 | #define INCL_DOSERRORS | 
|---|
|  | 3 | #define INCL_WIN | 
|---|
|  | 4 |  | 
|---|
|  | 5 | #include <os2.h> | 
|---|
|  | 6 | #include <stdarg.h> | 
|---|
|  | 7 | #include <stdio.h> | 
|---|
|  | 8 | #include <stdlib.h> | 
|---|
|  | 9 | #include <string.h> | 
|---|
|  | 10 | #include <ctype.h> | 
|---|
|  | 11 | #include "fm3dll.h" | 
|---|
|  | 12 | #include "fm3dlg.h" | 
|---|
|  | 13 | #include "fm3str.h" | 
|---|
|  | 14 |  | 
|---|
|  | 15 | #pragma alloc_text(MKDIR,MassMkdir,SetDir,PMMkDir,SetTargetDir) | 
|---|
|  | 16 |  | 
|---|
|  | 17 |  | 
|---|
|  | 18 | APIRET MassMkdir (HWND hwndClient,CHAR *dir) { | 
|---|
|  | 19 |  | 
|---|
|  | 20 | APIRET last,was = 0; | 
|---|
|  | 21 | CHAR  *p; | 
|---|
|  | 22 | CHAR   s[CCHMAXPATH]; | 
|---|
|  | 23 |  | 
|---|
|  | 24 | if(DosQueryPathInfo(dir, | 
|---|
|  | 25 | FIL_QUERYFULLNAME, | 
|---|
|  | 26 | s, | 
|---|
|  | 27 | sizeof(s))) | 
|---|
|  | 28 | strcpy(s,dir); | 
|---|
|  | 29 | p = s; | 
|---|
|  | 30 | while(*p) { | 
|---|
|  | 31 | if(*p == '/') | 
|---|
|  | 32 | *p = '\\'; | 
|---|
|  | 33 | p++; | 
|---|
|  | 34 | } | 
|---|
|  | 35 | p = s; | 
|---|
|  | 36 | do { | 
|---|
|  | 37 | p = strchr(p,'\\'); | 
|---|
|  | 38 | if(p && | 
|---|
|  | 39 | p > s && | 
|---|
|  | 40 | *(p - 1) == ':') | 
|---|
|  | 41 | p = strchr(p + 1,'\\'); | 
|---|
|  | 42 | if(p && | 
|---|
|  | 43 | *p) { | 
|---|
|  | 44 | *p = 0; | 
|---|
|  | 45 | was = 1; | 
|---|
|  | 46 | } | 
|---|
|  | 47 | else | 
|---|
|  | 48 | was = 0; | 
|---|
|  | 49 | last = DosCreateDir(s,NULL); | 
|---|
|  | 50 | if(!last) | 
|---|
|  | 51 | Broadcast((HAB)0, | 
|---|
|  | 52 | hwndClient, | 
|---|
|  | 53 | UM_UPDATERECORD, | 
|---|
|  | 54 | MPFROMP(s), | 
|---|
|  | 55 | MPVOID); | 
|---|
|  | 56 | else if(last == ERROR_ACCESS_DENIED) { | 
|---|
|  | 57 | if(!IsFile(s)) | 
|---|
|  | 58 | last = 0; | 
|---|
|  | 59 | } | 
|---|
|  | 60 | if(was) { | 
|---|
|  | 61 | *p = '\\'; | 
|---|
|  | 62 | p++; | 
|---|
|  | 63 | } | 
|---|
|  | 64 | } | 
|---|
|  | 65 | while(p && | 
|---|
|  | 66 | *p); | 
|---|
|  | 67 | return last; | 
|---|
|  | 68 | } | 
|---|
|  | 69 |  | 
|---|
|  | 70 |  | 
|---|
|  | 71 | APIRET SetDir (HWND hwndClient,HWND hwnd,CHAR *dir,INT flags) { | 
|---|
|  | 72 |  | 
|---|
|  | 73 | /* | 
|---|
|  | 74 | * bitmapped flags: | 
|---|
|  | 75 | * 1 = don't ask to create if non-existent | 
|---|
|  | 76 | */ | 
|---|
|  | 77 |  | 
|---|
|  | 78 | CHAR        s[CCHMAXPATH],*p; | 
|---|
|  | 79 | APIRET      ret = 0,error; | 
|---|
|  | 80 | INT         isfile; | 
|---|
|  | 81 |  | 
|---|
|  | 82 | if(DosQueryPathInfo(dir, | 
|---|
|  | 83 | FIL_QUERYFULLNAME, | 
|---|
|  | 84 | s, | 
|---|
|  | 85 | sizeof(s))) | 
|---|
|  | 86 | strcpy(s,dir); | 
|---|
|  | 87 | while((p = strchr(s,'/')) != NULL) | 
|---|
|  | 88 | *p = '\\'; | 
|---|
|  | 89 | while(strlen(s) > 3 && | 
|---|
|  | 90 | s[strlen(s) - 1] == '\\') | 
|---|
|  | 91 | s[strlen(s) - 1] = 0; | 
|---|
|  | 92 | if(IsFullName(s)) { | 
|---|
|  | 93 | if(driveflags[toupper(*s) - 'A'] & (DRIVE_IGNORE | DRIVE_INVALID)) { | 
|---|
|  | 94 | if(!(flags & 1)) | 
|---|
|  | 95 | saymsg(MB_CANCEL, | 
|---|
|  | 96 | hwnd, | 
|---|
|  | 97 | GetPString(IDS_NOPETEXT), | 
|---|
|  | 98 | GetPString(IDS_DRIVEISTEXT), | 
|---|
|  | 99 | toupper(*s), | 
|---|
|  | 100 | ((driveflags[toupper(*s) - 'A'] & DRIVE_IGNORE) != 0) ? | 
|---|
|  | 101 | GetPString(IDS_BEINGIGNOREDTEXT) : | 
|---|
|  | 102 | GetPString(IDS_INVALIDTEXT)); | 
|---|
|  | 103 | return -5; | 
|---|
|  | 104 | } | 
|---|
|  | 105 | } | 
|---|
|  | 106 | isfile = IsFile(s); | 
|---|
|  | 107 | if(isfile == -1) { | 
|---|
|  | 108 | if(IsFullName(s)) { | 
|---|
|  | 109 | if(driveflags[toupper(*s) - 'A'] & DRIVE_NOTWRITEABLE) { | 
|---|
|  | 110 | if(!(flags & 1)) | 
|---|
|  | 111 | saymsg(MB_CANCEL, | 
|---|
|  | 112 | hwnd, | 
|---|
|  | 113 | GetPString(IDS_NOPETEXT), | 
|---|
|  | 114 | GetPString(IDS_DRIVEISTEXT), | 
|---|
|  | 115 | toupper(*s), | 
|---|
|  | 116 | GetPString(IDS_NOWRITETEXT)); | 
|---|
|  | 117 | return -4; | 
|---|
|  | 118 | } | 
|---|
|  | 119 | } | 
|---|
|  | 120 | if(!(flags & 1)) { | 
|---|
|  | 121 | if(saymsg(MB_YESNO, | 
|---|
|  | 122 | hwnd, | 
|---|
|  | 123 | GetPString(IDS_CONFIRMTEXT), | 
|---|
|  | 124 | GetPString(IDS_NODIRCREATEDIRTEXT), | 
|---|
|  | 125 | s) != | 
|---|
|  | 126 | MBID_YES) | 
|---|
|  | 127 | return -3; | 
|---|
|  | 128 | } | 
|---|
|  | 129 | error = MassMkdir(hwndClient,s); | 
|---|
|  | 130 | if(error) { | 
|---|
|  | 131 | Dos_Error(MB_CANCEL, | 
|---|
|  | 132 | error, | 
|---|
|  | 133 | hwnd, | 
|---|
|  | 134 | __FILE__, | 
|---|
|  | 135 | __LINE__, | 
|---|
|  | 136 | GetPString(IDS_CREATEDIRFAILEDTEXT), | 
|---|
|  | 137 | s); | 
|---|
|  | 138 | ret = -1; | 
|---|
|  | 139 | } | 
|---|
|  | 140 | } | 
|---|
|  | 141 | else if(isfile) { | 
|---|
|  | 142 | saymsg(MB_CANCEL | MB_ICONEXCLAMATION, | 
|---|
|  | 143 | hwnd, | 
|---|
|  | 144 | GetPString(IDS_ERRORTEXT), | 
|---|
|  | 145 | GetPString(IDS_EXISTSNOTDIRTEXT), | 
|---|
|  | 146 | s); | 
|---|
|  | 147 | ret = -2; | 
|---|
|  | 148 | } | 
|---|
|  | 149 | return ret; | 
|---|
|  | 150 | } | 
|---|
|  | 151 |  | 
|---|
|  | 152 |  | 
|---|
|  | 153 | BOOL PMMkDir (HWND hwnd,CHAR *filename,BOOL copy) { | 
|---|
|  | 154 |  | 
|---|
|  | 155 | STRINGINPARMS sip; | 
|---|
|  | 156 | CHAR          szBuff[CCHMAXPATH]; | 
|---|
|  | 157 | APIRET        error; | 
|---|
|  | 158 |  | 
|---|
|  | 159 | Over: | 
|---|
|  | 160 | sip.help = GetPString(IDS_MKDIRHELPTEXT); | 
|---|
|  | 161 | sip.ret = szBuff; | 
|---|
|  | 162 | if(filename) | 
|---|
|  | 163 | strcpy(szBuff,filename); | 
|---|
|  | 164 | else | 
|---|
|  | 165 | save_dir2(szBuff); | 
|---|
|  | 166 | MakeValidDir(szBuff); | 
|---|
|  | 167 | if(*szBuff && | 
|---|
|  | 168 | szBuff[strlen(szBuff) - 1] != '\\') | 
|---|
|  | 169 | strcat(szBuff,"\\"); | 
|---|
|  | 170 | sip.prompt = GetPString(IDS_MKDIRPROMPTTEXT); | 
|---|
|  | 171 | sip.inputlen = CCHMAXPATH - 1; | 
|---|
|  | 172 | sip.title = GetPString(IDS_MKDIRTITLETEXT); | 
|---|
|  | 173 | if(WinDlgBox(HWND_DESKTOP, | 
|---|
|  | 174 | hwnd, | 
|---|
|  | 175 | InputDlgProc, | 
|---|
|  | 176 | FM3ModHandle, | 
|---|
|  | 177 | STR_FRAME, | 
|---|
|  | 178 | &sip) && | 
|---|
|  | 179 | *szBuff) { | 
|---|
|  | 180 | if((strchr(szBuff,'?') || | 
|---|
|  | 181 | strchr(szBuff,'*')) || | 
|---|
|  | 182 | IsFile(szBuff) == 1 || | 
|---|
|  | 183 | IsRoot(szBuff)) { | 
|---|
|  | 184 | saymsg(MB_ENTER | MB_ICONEXCLAMATION, | 
|---|
|  | 185 | hwnd, | 
|---|
|  | 186 | GetPString(IDS_ERRORTEXT), | 
|---|
|  | 187 | GetPString(IDS_DIRNAMEERRORTEXT), | 
|---|
|  | 188 | szBuff); | 
|---|
|  | 189 | goto Over; | 
|---|
|  | 190 | } | 
|---|
|  | 191 | error = MassMkdir(hwnd, | 
|---|
|  | 192 | szBuff); | 
|---|
|  | 193 | if(error) | 
|---|
|  | 194 | Dos_Error(MB_ENTER, | 
|---|
|  | 195 | error, | 
|---|
|  | 196 | hwnd, | 
|---|
|  | 197 | __FILE__, | 
|---|
|  | 198 | __LINE__, | 
|---|
|  | 199 | GetPString(IDS_CREATEDIRFAILEDTEXT), | 
|---|
|  | 200 | szBuff); | 
|---|
|  | 201 | else { | 
|---|
|  | 202 | if(copy && | 
|---|
|  | 203 | filename) | 
|---|
|  | 204 | strcpy(filename, | 
|---|
|  | 205 | szBuff); | 
|---|
|  | 206 | return TRUE; | 
|---|
|  | 207 | } | 
|---|
|  | 208 | } | 
|---|
|  | 209 | return FALSE; | 
|---|
|  | 210 | } | 
|---|
|  | 211 |  | 
|---|
|  | 212 |  | 
|---|
|  | 213 | void SetTargetDir (HWND hwnd,BOOL justshow) { | 
|---|
|  | 214 |  | 
|---|
|  | 215 | char temp[CCHMAXPATH + 12]; | 
|---|
|  | 216 |  | 
|---|
|  | 217 | if(!justshow) { | 
|---|
|  | 218 | strcpy(temp, | 
|---|
|  | 219 | targetdir); | 
|---|
|  | 220 | if(WinDlgBox(HWND_DESKTOP, | 
|---|
|  | 221 | hwnd, | 
|---|
|  | 222 | WalkTargetDlgProc, | 
|---|
|  | 223 | FM3ModHandle, | 
|---|
|  | 224 | WALK_FRAME, | 
|---|
|  | 225 | MPFROMP(temp)) && | 
|---|
|  | 226 | *temp) { | 
|---|
|  | 227 | strcpy(targetdir,temp); | 
|---|
|  | 228 | if(!fChangeTarget) | 
|---|
|  | 229 | PrfWriteProfileString(fmprof, | 
|---|
|  | 230 | appname, | 
|---|
|  | 231 | "Targetdir", | 
|---|
|  | 232 | targetdir); | 
|---|
|  | 233 | } | 
|---|
|  | 234 | else { | 
|---|
|  | 235 | if(*targetdir && | 
|---|
|  | 236 | saymsg(MB_YESNOCANCEL, | 
|---|
|  | 237 | hwnd, | 
|---|
|  | 238 | GetPString(IDS_CLEARTARGETTITLETEXT), | 
|---|
|  | 239 | "%s", | 
|---|
|  | 240 | GetPString(IDS_CLEARTARGETTEXT)) == MBID_YES) { | 
|---|
|  | 241 | *targetdir = 0; | 
|---|
|  | 242 | PrfWriteProfileString(fmprof, | 
|---|
|  | 243 | appname, | 
|---|
|  | 244 | "Targetdir", | 
|---|
|  | 245 | NULL); | 
|---|
|  | 246 | } | 
|---|
|  | 247 | } | 
|---|
|  | 248 | } | 
|---|
|  | 249 |  | 
|---|
|  | 250 | if(hwndBack) { | 
|---|
|  | 251 | if(fShowTarget) | 
|---|
|  | 252 | sprintf(temp, | 
|---|
|  | 253 | "%s%s%s%s", | 
|---|
|  | 254 | GetPString(IDS_TARGETDIRTITLETEXT), | 
|---|
|  | 255 | (*targetdir) ? "" : "<", | 
|---|
|  | 256 | (*targetdir) ? | 
|---|
|  | 257 | targetdir : | 
|---|
|  | 258 | GetPString(IDS_NONE), | 
|---|
|  | 259 | (*targetdir) ? "" : ">"); | 
|---|
|  | 260 | else | 
|---|
|  | 261 | *temp = 0; | 
|---|
|  | 262 | WinSetWindowText(hwndBack,temp); | 
|---|
|  | 263 | } | 
|---|
|  | 264 | } | 
|---|
|  | 265 |  | 
|---|