[29] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: copyf.c 1443 2009-07-16 21:19:04Z stevenhl $
|
---|
| 5 |
|
---|
| 6 | Copy functions
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1443] | 9 | Copyright (c) 2001, 2009 Steven H.Levine
|
---|
[29] | 10 |
|
---|
[173] | 11 | 14 Sep 02 SHL Drop obsolete debug code
|
---|
| 12 | 14 Oct 02 SHL Drop obsolete debug code
|
---|
| 13 | 10 Nov 02 SHL docopyf - don't forget to terminate longname
|
---|
[1163] | 14 | optimize longname logic
|
---|
[173] | 15 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 16 | 28 May 05 SHL Drop debug code
|
---|
[347] | 17 | 14 Jul 06 SHL Use Runtime_Error
|
---|
[793] | 18 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[827] | 19 | 01 Sep 07 GKY Use xDosSetPathInfo to fix case where FS3 buffer crosses 64k boundry
|
---|
[985] | 20 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[1082] | 21 | 19 Jul 08 GKY Modify MakeTempName for use making temp directory names
|
---|
[1402] | 22 | 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
|
---|
[1438] | 23 | 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
|
---|
[1439] | 24 | 12 Jul 09 GKY Add xDosQueryAppType and xDoxAlloc... to allow FM/2 to load in high memory
|
---|
[1443] | 25 | 13 Jul 09 SHL Drop obsolete code
|
---|
[29] | 26 |
|
---|
| 27 | ***********************************************************************/
|
---|
| 28 |
|
---|
[907] | 29 | #include <stdlib.h>
|
---|
| 30 | #include <string.h>
|
---|
| 31 | #include <stdarg.h>
|
---|
| 32 | #include <ctype.h>
|
---|
| 33 |
|
---|
[2] | 34 | #define INCL_DOS
|
---|
| 35 | #define INCL_DOSERRORS
|
---|
| 36 | #define INCL_WIN
|
---|
[841] | 37 | #define INCL_LONGLONG
|
---|
[2] | 38 |
|
---|
[1188] | 39 | #include "fm3dll.h"
|
---|
[1222] | 40 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1206] | 41 | #include "killproc.h" // Data declaration(s)
|
---|
| 42 | #include "notebook.h" // Data declaration(s)
|
---|
| 43 | #include "info.h" // Data declaration(s)
|
---|
| 44 | #include "init.h" // Data declaration(s)
|
---|
| 45 | #include "arccnrs.h"
|
---|
[907] | 46 | #include "fm3str.h"
|
---|
[1163] | 47 | #include "errutil.h" // Dos_Error...
|
---|
| 48 | #include "strutil.h" // GetPString
|
---|
| 49 | #include "copyf.h"
|
---|
| 50 | #include "literal.h" // fixup
|
---|
[1188] | 51 | #include "misc.h" // Broadcast
|
---|
| 52 | #include "valid.h" // MakeFullName
|
---|
| 53 | #include "wrappers.h" // xDosSetPathInfo
|
---|
| 54 | #include "strips.h" // bstrip
|
---|
[1438] | 55 | #include "fortify.h"
|
---|
| 56 | #include "pathutil.h" // AddBackslashToPath
|
---|
[2] | 57 |
|
---|
[347] | 58 | static PSZ pszSrcFile = __FILE__;
|
---|
| 59 |
|
---|
[1188] | 60 | static CHAR *GetLongName(CHAR * oldname, CHAR * buffer);
|
---|
| 61 | static CHAR *TruncName(CHAR * oldname, CHAR * buffer);
|
---|
| 62 |
|
---|
[1163] | 63 | //static CHAR default_disk(VOID);
|
---|
| 64 | //static INT unlink_allf(CHAR * string, ...);
|
---|
| 65 |
|
---|
[2] | 66 | #ifndef WinMoveObject
|
---|
[551] | 67 | HOBJECT APIENTRY WinMoveObject(HOBJECT hObjectofObject,
|
---|
[1163] | 68 | HOBJECT hObjectofDest, ULONG ulReserved);
|
---|
[2] | 69 | #endif
|
---|
| 70 | #ifndef WinCopyObject
|
---|
[551] | 71 | HOBJECT APIENTRY WinCopyObject(HOBJECT hObjectofObject,
|
---|
[1163] | 72 | HOBJECT hObjectofDest, ULONG ulReserved);
|
---|
[2] | 73 | #endif
|
---|
| 74 |
|
---|
[1082] | 75 | char *MakeTempName(char *buffer, char *temproot, INT type)
|
---|
[347] | 76 | {
|
---|
[843] | 77 | FILESTATUS3 fs3;
|
---|
[551] | 78 | APIRET rc;
|
---|
| 79 | char *p, *o;
|
---|
[2] | 80 |
|
---|
[1438] | 81 | if (strlen(buffer) > 3) // && buffer[strlen(buffer) - 1] != '\\')
|
---|
| 82 | AddBackslashToPath(buffer);
|
---|
| 83 | //strcat(buffer, "\\");
|
---|
[2] | 84 | p = o = buffer + strlen(buffer);
|
---|
[1082] | 85 | switch (type) {
|
---|
| 86 | case 0:
|
---|
| 87 | sprintf(p, "%08lx.%03lx", rand() & 4095L, mypid);
|
---|
| 88 | break;
|
---|
| 89 | case 1:
|
---|
| 90 | sprintf(p, "%s%04lx.%03lx", "$FM2", rand() & 4095L, mypid);
|
---|
| 91 | break;
|
---|
| 92 | case 2:
|
---|
| 93 | sprintf(p, "%s.%03x", temproot, (rand() & 4095));
|
---|
| 94 | break;
|
---|
| 95 | default:
|
---|
| 96 | break;
|
---|
| 97 | }
|
---|
[2] | 98 | p = buffer + (strlen(buffer) - 1);
|
---|
[551] | 99 | for (;;) {
|
---|
[2] | 100 | DosError(FERR_DISABLEHARDERR);
|
---|
[843] | 101 | rc = DosQueryPathInfo(buffer, FIL_STANDARD, &fs3, sizeof(fs3));
|
---|
[551] | 102 | if (rc == ERROR_DISK_CHANGE) {
|
---|
[2] | 103 | DosError(FERR_ENABLEHARDERR);
|
---|
[843] | 104 | rc = DosQueryPathInfo(buffer, FIL_STANDARD, &fs3, sizeof(fs3));
|
---|
[2] | 105 | }
|
---|
[551] | 106 | if (rc)
|
---|
[2] | 107 | break;
|
---|
[551] | 108 | Loop:
|
---|
| 109 | if (p < o) {
|
---|
[2] | 110 | *buffer = 0;
|
---|
| 111 | return NULL;
|
---|
| 112 | }
|
---|
[551] | 113 | if ((*p) + 1 < 'Z' + 1) {
|
---|
[2] | 114 | (*p)++;
|
---|
[551] | 115 | while (strchr("*?<>\":/\\|+=;,[]. ", *p))
|
---|
[1163] | 116 | (*p)++;
|
---|
[2] | 117 | *p = toupper(*p);
|
---|
| 118 | }
|
---|
| 119 | else {
|
---|
| 120 | p--;
|
---|
[551] | 121 | if (p >= o && *p == '.')
|
---|
[1163] | 122 | p--;
|
---|
[2] | 123 | goto Loop;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | return buffer;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[551] | 129 | CHAR *TruncName(CHAR * oldname, CHAR * buffer)
|
---|
[347] | 130 | {
|
---|
[551] | 131 | CHAR *p, *f, *s, *o;
|
---|
[843] | 132 | FILESTATUS3 fs3;
|
---|
[551] | 133 | APIRET rc;
|
---|
[2] | 134 |
|
---|
[551] | 135 | if (!buffer || !oldname || !*oldname) {
|
---|
| 136 | if (buffer)
|
---|
[2] | 137 | *buffer = 0;
|
---|
| 138 | return NULL;
|
---|
| 139 | }
|
---|
[551] | 140 | strcpy(buffer, oldname);
|
---|
| 141 | f = strrchr(buffer, '\\');
|
---|
| 142 | if (!f)
|
---|
| 143 | f = strrchr(buffer, '/');
|
---|
| 144 | if (!f)
|
---|
[2] | 145 | f = buffer;
|
---|
| 146 | else
|
---|
| 147 | f++;
|
---|
| 148 | p = f;
|
---|
| 149 | o = p;
|
---|
| 150 | f = oldname + (f - buffer);
|
---|
| 151 | strupr(buffer);
|
---|
[1163] | 152 | while (*f == '.') /* skip leading '.'s */
|
---|
[2] | 153 | f++;
|
---|
| 154 | s = f;
|
---|
[1163] | 155 | while (*f && *f != '.' && f < s + 8) { /* skip past rootname */
|
---|
[2] | 156 | *p = toupper(*f);
|
---|
| 157 | p++;
|
---|
| 158 | f++;
|
---|
| 159 | }
|
---|
[551] | 160 | while (*f == '.')
|
---|
[2] | 161 | f++;
|
---|
| 162 | s = f;
|
---|
[551] | 163 | f = strrchr(f, '.');
|
---|
| 164 | if (f) {
|
---|
| 165 | while (*f == '.')
|
---|
[2] | 166 | f++;
|
---|
| 167 | }
|
---|
[551] | 168 | if (f && *(f + 1))
|
---|
[2] | 169 | s = f;
|
---|
| 170 | else
|
---|
| 171 | f = s;
|
---|
[551] | 172 | if (*f) {
|
---|
[2] | 173 | *p = '.';
|
---|
| 174 | p++;
|
---|
[551] | 175 | while (*f && *f != '.' && f < s + 3) {
|
---|
[2] | 176 | *p = toupper(*f);
|
---|
| 177 | p++;
|
---|
| 178 | f++;
|
---|
| 179 | }
|
---|
| 180 | }
|
---|
| 181 | *p = 0;
|
---|
| 182 |
|
---|
| 183 | p = o;
|
---|
[551] | 184 | while (*p) {
|
---|
| 185 | if (strchr("*?<>\":/\\|+=;,[] ", *p) || *p < 0x20)
|
---|
[2] | 186 | *p = '_';
|
---|
[551] | 187 | if (*p == '.' && *(p + 1) == '.')
|
---|
[2] | 188 | *(p + 1) = '_';
|
---|
| 189 | p++;
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | p = o + (strlen(o) - 1);
|
---|
[551] | 193 | for (;;) {
|
---|
[2] | 194 | DosError(FERR_DISABLEHARDERR);
|
---|
[843] | 195 | rc = DosQueryPathInfo(buffer, FIL_STANDARD, &fs3, sizeof(fs3));
|
---|
[551] | 196 | if (rc == ERROR_DISK_CHANGE) {
|
---|
[2] | 197 | DosError(FERR_ENABLEHARDERR);
|
---|
[843] | 198 | rc = DosQueryPathInfo(buffer, FIL_STANDARD, &fs3, sizeof(fs3));
|
---|
[2] | 199 | }
|
---|
[551] | 200 | if (rc)
|
---|
[2] | 201 | break;
|
---|
[551] | 202 | Loop:
|
---|
| 203 | if (p < o) {
|
---|
[2] | 204 | *buffer = 0;
|
---|
| 205 | return NULL;
|
---|
| 206 | }
|
---|
[551] | 207 | if ((*p) + 1 < 'Z' + 1) {
|
---|
[2] | 208 | (*p)++;
|
---|
[551] | 209 | while (strchr("*?<>\":/\\|+=;,[]. ", *p))
|
---|
[1163] | 210 | (*p)++;
|
---|
[2] | 211 | *p = toupper(*p);
|
---|
| 212 | }
|
---|
| 213 | else {
|
---|
| 214 | p--;
|
---|
[551] | 215 | if (p >= o && *p == '.')
|
---|
[1163] | 216 | p--;
|
---|
[2] | 217 | goto Loop;
|
---|
| 218 | }
|
---|
| 219 | }
|
---|
| 220 | return buffer;
|
---|
| 221 | }
|
---|
| 222 |
|
---|
[551] | 223 | CHAR *GetLongName(CHAR * oldname, CHAR * longname)
|
---|
[347] | 224 | {
|
---|
[551] | 225 | if (!longname)
|
---|
[2] | 226 | return NULL;
|
---|
| 227 | *longname = 0;
|
---|
[551] | 228 | if (!oldname || !*oldname)
|
---|
[2] | 229 | return NULL;
|
---|
[551] | 230 | if (IsFullName(oldname)) {
|
---|
[2] | 231 |
|
---|
[551] | 232 | APIRET rc;
|
---|
| 233 | EAOP2 eaop;
|
---|
[2] | 234 | PGEA2LIST pgealist;
|
---|
| 235 | PFEA2LIST pfealist;
|
---|
[551] | 236 | PGEA2 pgea;
|
---|
| 237 | PFEA2 pfea;
|
---|
| 238 | CHAR *value;
|
---|
[2] | 239 |
|
---|
[551] | 240 | strcpy(longname, oldname);
|
---|
[2] | 241 | value = longname;
|
---|
[551] | 242 | while (*value) {
|
---|
| 243 | if (*value == '/')
|
---|
[1163] | 244 | *value = '\\';
|
---|
[2] | 245 | value++;
|
---|
| 246 | }
|
---|
[551] | 247 | value = strrchr(longname, '\\');
|
---|
| 248 | if (value) {
|
---|
[2] | 249 | value++;
|
---|
| 250 | *value = 0;
|
---|
| 251 | }
|
---|
[551] | 252 | pgealist = xmallocz(sizeof(GEA2LIST) + 32, pszSrcFile, __LINE__);
|
---|
[347] | 253 | if (pgealist) {
|
---|
[2] | 254 | pgea = &pgealist->list[0];
|
---|
[551] | 255 | strcpy(pgea->szName, LONGNAME);
|
---|
[2] | 256 | pgea->cbName = strlen(pgea->szName);
|
---|
| 257 | pgea->oNextEntryOffset = 0L;
|
---|
| 258 | pgealist->cbList = (sizeof(GEA2LIST) + pgea->cbName);
|
---|
[551] | 259 | pfealist = xmallocz(1536, pszSrcFile, __LINE__);
|
---|
[347] | 260 | if (pfealist) {
|
---|
[1163] | 261 | pfealist->cbList = 1024;
|
---|
| 262 | eaop.fpGEA2List = pgealist;
|
---|
| 263 | eaop.fpFEA2List = pfealist;
|
---|
| 264 | eaop.oError = 0L;
|
---|
| 265 | DosError(FERR_DISABLEHARDERR);
|
---|
| 266 | rc = DosQueryPathInfo(oldname,
|
---|
| 267 | FIL_QUERYEASFROMLIST,
|
---|
| 268 | (PVOID) & eaop, (ULONG) sizeof(EAOP2));
|
---|
| 269 | if (!rc) {
|
---|
| 270 | pfea = &eaop.fpFEA2List->list[0];
|
---|
| 271 | value = pfea->szName + pfea->cbName + 1;
|
---|
| 272 | value[pfea->cbValue] = 0;
|
---|
| 273 | if (*(USHORT *) value == EAT_ASCII)
|
---|
| 274 | strncat(longname,
|
---|
| 275 | value + (sizeof(USHORT) * 2),
|
---|
| 276 | CCHMAXPATH - strlen(longname));
|
---|
| 277 | longname[CCHMAXPATH - 1] = 0;
|
---|
| 278 | }
|
---|
| 279 | free(pfealist);
|
---|
[2] | 280 | }
|
---|
[1039] | 281 | free(pgealist);
|
---|
[2] | 282 | }
|
---|
| 283 | }
|
---|
| 284 | return longname;
|
---|
| 285 | }
|
---|
| 286 |
|
---|
[551] | 287 | BOOL ZapLongName(char *filename)
|
---|
[347] | 288 | {
|
---|
[1438] | 289 | return WriteLongName(filename, NullStr);
|
---|
[2] | 290 | }
|
---|
| 291 |
|
---|
[551] | 292 | BOOL WriteLongName(CHAR * filename, CHAR * longname)
|
---|
[347] | 293 | {
|
---|
[551] | 294 | APIRET rc;
|
---|
| 295 | EAOP2 eaop;
|
---|
[2] | 296 | PFEA2LIST pfealist = NULL;
|
---|
[551] | 297 | ULONG ealen;
|
---|
| 298 | USHORT len;
|
---|
| 299 | CHAR *eaval, *p;
|
---|
[2] | 300 |
|
---|
[551] | 301 | if (!filename || !*filename || !longname)
|
---|
[2] | 302 | return FALSE;
|
---|
[551] | 303 | p = strrchr(longname, '\\');
|
---|
| 304 | if (p)
|
---|
| 305 | memmove(longname, p + 1, strlen(p + 1) + 1);
|
---|
| 306 | p = strrchr(longname, '/');
|
---|
| 307 | if (p)
|
---|
| 308 | memmove(longname, p + 1, strlen(p + 1) + 1);
|
---|
[123] | 309 | bstrip(longname);
|
---|
[2] | 310 | len = strlen(longname);
|
---|
[551] | 311 | if (len)
|
---|
[2] | 312 | ealen = sizeof(FEA2LIST) + 10 + len + 4;
|
---|
| 313 | else
|
---|
| 314 | ealen = sizeof(FEALIST) + 10;
|
---|
[1438] | 315 | rc = xDosAllocMem((PPVOID) & pfealist,
|
---|
[1439] | 316 | ealen + 32L, PAG_COMMIT | PAG_READ | PAG_WRITE,
|
---|
| 317 | pszSrcFile, __LINE__);
|
---|
[347] | 318 | if (rc)
|
---|
[551] | 319 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
[1163] | 320 | GetPString(IDS_OUTOFMEMORY));
|
---|
[347] | 321 | else {
|
---|
[551] | 322 | memset(pfealist, 0, ealen + 1);
|
---|
[2] | 323 | pfealist->cbList = ealen;
|
---|
[841] | 324 | pfealist->list[0].oNextEntryOffset = 0;
|
---|
[2] | 325 | pfealist->list[0].fEA = 0;
|
---|
| 326 | pfealist->list[0].cbName = 9;
|
---|
[551] | 327 | strcpy(pfealist->list[0].szName, LONGNAME);
|
---|
| 328 | if (len) {
|
---|
[2] | 329 | eaval = pfealist->list[0].szName + 10;
|
---|
[551] | 330 | *(USHORT *) eaval = (USHORT) EAT_ASCII;
|
---|
[2] | 331 | eaval += sizeof(USHORT);
|
---|
[551] | 332 | *(USHORT *) eaval = (USHORT) len;
|
---|
[2] | 333 | eaval += sizeof(USHORT);
|
---|
[551] | 334 | memcpy(eaval, longname, len);
|
---|
[2] | 335 | pfealist->list[0].cbValue = len + (sizeof(USHORT) * 2);
|
---|
| 336 | }
|
---|
| 337 | else
|
---|
| 338 | pfealist->list[0].cbValue = 0;
|
---|
[551] | 339 | eaop.fpGEA2List = (PGEA2LIST) 0;
|
---|
[2] | 340 | eaop.fpFEA2List = pfealist;
|
---|
| 341 | eaop.oError = 0L;
|
---|
| 342 | DosError(FERR_DISABLEHARDERR);
|
---|
[827] | 343 | rc = xDosSetPathInfo(filename, FIL_QUERYEASIZE,
|
---|
[1163] | 344 | &eaop, sizeof(eaop), DSPI_WRTTHRU);
|
---|
[2] | 345 | DosFreeMem(pfealist);
|
---|
[551] | 346 | if (rc)
|
---|
[2] | 347 | return FALSE;
|
---|
| 348 | }
|
---|
| 349 | return TRUE;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
[551] | 352 | BOOL AdjustWildcardName(CHAR * oldname, CHAR * newname)
|
---|
[347] | 353 | {
|
---|
[2] | 354 | BOOL ret = FALSE;
|
---|
| 355 |
|
---|
[827] | 356 | /* NOTE: newname should be CCHMAXPATH chars long! */
|
---|
[2] | 357 |
|
---|
[551] | 358 | if (strchr(newname, '*') || strchr(newname, '?')) {
|
---|
[2] | 359 |
|
---|
[551] | 360 | CHAR srce[CCHMAXPATHCOMP], dest[CCHMAXPATHCOMP], result[CCHMAXPATHCOMP],
|
---|
[1321] | 361 | *p;
|
---|
[2] | 362 |
|
---|
[551] | 363 | p = strrchr(newname, '\\');
|
---|
| 364 | if (p && *(p + 1)) {
|
---|
| 365 | strcpy(dest, p + 1);
|
---|
| 366 | p = strrchr(oldname, '\\');
|
---|
| 367 | if (p && *(p + 1)) {
|
---|
[1163] | 368 | strcpy(srce, p + 1);
|
---|
| 369 | DosError(FERR_DISABLEHARDERR);
|
---|
[1321] | 370 | if (!DosEditName(1L, srce, dest, (PBYTE)result, (ULONG)sizeof(result))) {
|
---|
[1163] | 371 | p = strrchr(newname, '\\');
|
---|
| 372 | p++;
|
---|
| 373 | strcpy(p, result);
|
---|
| 374 | ret = TRUE;
|
---|
| 375 | }
|
---|
[2] | 376 | }
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 | return ret;
|
---|
| 380 | }
|
---|
| 381 |
|
---|
[1402] | 382 | APIRET docopyf(INT type, CHAR *oldname, CHAR *newname)
|
---|
[347] | 383 | {
|
---|
[2] | 384 | /*
|
---|
| 385 | * returns:
|
---|
| 386 | * 0: success
|
---|
| 387 | * -1: bad string parameter(s)
|
---|
| 388 | * -2: source didn't exist
|
---|
| 389 | * -3: bad type
|
---|
[827] | 390 | * anything else: API return
|
---|
[2] | 391 | */
|
---|
| 392 |
|
---|
[1402] | 393 | CHAR longname[CCHMAXPATH], shortname[CCHMAXPATH];
|
---|
[551] | 394 | CHAR olddisk, newdisk, dir[CCHMAXPATH], *p, *pp;
|
---|
| 395 | APIRET ret = -1, rc;
|
---|
[841] | 396 | FILESTATUS3L st, st2, dummy;
|
---|
[551] | 397 | BOOL diskchange = FALSE, zaplong = FALSE;
|
---|
[2] | 398 |
|
---|
[1402] | 399 | *shortname = *dir = 0;
|
---|
[2] | 400 |
|
---|
[1402] | 401 | if (!oldname || !*oldname || !*newname) /* bad string args */
|
---|
[551] | 402 | return (APIRET) - 1;
|
---|
[29] | 403 |
|
---|
[2] | 404 | DosError(FERR_DISABLEHARDERR);
|
---|
[841] | 405 | if (DosQueryPathInfo(oldname, FIL_STANDARDL, &st, sizeof(FILESTATUS3L)))
|
---|
[1163] | 406 | return (APIRET) - 2; /* no source */
|
---|
[29] | 407 |
|
---|
[1402] | 408 | AdjustWildcardName(oldname, newname);
|
---|
[2] | 409 | MakeFullName(oldname);
|
---|
[1402] | 410 | MakeFullName(newname);
|
---|
[1163] | 411 | olddisk = toupper(*oldname); /* source drive */
|
---|
[1402] | 412 | newdisk = toupper(*newname); /* destination drive */
|
---|
[551] | 413 | if (!(driveflags[toupper(*oldname) - 'A'] & DRIVE_NOLONGNAMES))
|
---|
[45] | 414 | *longname = 0;
|
---|
[551] | 415 | else {
|
---|
[45] | 416 | GetLongName(oldname, longname);
|
---|
[551] | 417 | if (*longname) {
|
---|
[2] | 418 | p = RootName(longname);
|
---|
[551] | 419 | if (p != longname)
|
---|
[1163] | 420 | memmove(longname, p, strlen(p) + 1);
|
---|
[2] | 421 | }
|
---|
[45] | 422 | }
|
---|
| 423 | /* If root name changed make sure longname EA goes away */
|
---|
| 424 | p = RootName(oldname);
|
---|
[1402] | 425 | pp = RootName(newname);
|
---|
[551] | 426 | if (stricmp(p, pp)) {
|
---|
[45] | 427 | zaplong = TRUE;
|
---|
[2] | 428 | }
|
---|
| 429 |
|
---|
| 430 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 431 | switch (type) {
|
---|
| 432 | case WPSMOVE:
|
---|
| 433 | {
|
---|
| 434 | HOBJECT hobjsrc;
|
---|
| 435 | HOBJECT hobjdest;
|
---|
[2] | 436 |
|
---|
[551] | 437 | ret = ERROR_FILE_NOT_FOUND;
|
---|
| 438 | hobjsrc = WinQueryObject(oldname);
|
---|
| 439 | if (hobjsrc) {
|
---|
[1402] | 440 | strcpy(dir, newname);
|
---|
[1163] | 441 | p = strrchr(dir, '\\');
|
---|
| 442 | if (p < dir + 3)
|
---|
| 443 | p++;
|
---|
| 444 | *p = 0;
|
---|
| 445 | ret = ERROR_PATH_NOT_FOUND;
|
---|
| 446 | hobjdest = WinQueryObject(dir);
|
---|
| 447 | if (hobjdest) {
|
---|
| 448 | ret = ERROR_GEN_FAILURE;
|
---|
| 449 | hobjsrc = WinMoveObject(hobjsrc, hobjdest, 0);
|
---|
| 450 | if (hobjsrc)
|
---|
| 451 | ret = 0;
|
---|
| 452 | }
|
---|
[2] | 453 | }
|
---|
[551] | 454 | }
|
---|
| 455 | return ret;
|
---|
[2] | 456 |
|
---|
[551] | 457 | case WPSCOPY:
|
---|
| 458 | {
|
---|
| 459 | HOBJECT hobjsrc;
|
---|
| 460 | HOBJECT hobjdest;
|
---|
[2] | 461 |
|
---|
[551] | 462 | ret = ERROR_FILE_NOT_FOUND;
|
---|
| 463 | hobjsrc = WinQueryObject(oldname);
|
---|
| 464 | if (hobjsrc) {
|
---|
[1402] | 465 | strcpy(dir, newname);
|
---|
[1163] | 466 | p = strrchr(dir, '\\');
|
---|
| 467 | if (p < dir + 3)
|
---|
| 468 | p++;
|
---|
| 469 | *p = 0;
|
---|
| 470 | ret = ERROR_PATH_NOT_FOUND;
|
---|
| 471 | hobjdest = WinQueryObject(dir);
|
---|
| 472 | if (hobjdest) {
|
---|
| 473 | ret = ERROR_GEN_FAILURE;
|
---|
| 474 | hobjsrc = WinCopyObject(hobjsrc, hobjdest, 0);
|
---|
| 475 | if (hobjsrc)
|
---|
| 476 | ret = 0;
|
---|
| 477 | }
|
---|
[2] | 478 | }
|
---|
[551] | 479 | }
|
---|
| 480 | return ret;
|
---|
[2] | 481 |
|
---|
[551] | 482 | case MOVE:
|
---|
| 483 | *dir = 0;
|
---|
[1163] | 484 | if (olddisk == newdisk) { /* same drive */
|
---|
[551] | 485 | /* make temporary copy in case move fails */
|
---|
[1402] | 486 | if (IsFile(newname) != -1 && stricmp(oldname, newname)) {
|
---|
| 487 | strcpy(dir, newname);
|
---|
[1438] | 488 | AddBackslashToPath(dir);
|
---|
| 489 | //p = strrchr(dir, '\\');
|
---|
| 490 | //if (p)
|
---|
| 491 | // *p = 0;
|
---|
| 492 | //strcat(dir, "\\");
|
---|
[1163] | 493 | MakeTempName(dir, NULL, 0);
|
---|
[1402] | 494 | if (DosMove(newname, dir))
|
---|
[1163] | 495 | *dir = 0;
|
---|
[2] | 496 | }
|
---|
[551] | 497 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 498 | ret = DosMove(oldname, newname); /* move it */
|
---|
[1163] | 499 | if (ret && *dir) { /* failed -- clean up */
|
---|
| 500 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 501 | if (!DosMove(dir, newname))
|
---|
[1163] | 502 | Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
|
---|
[551] | 503 | }
|
---|
| 504 | else if (!ret && *dir) {
|
---|
[1163] | 505 | if (!IsFile(dir)) {
|
---|
| 506 | if (!strchr(dir, '?') && !strchr(dir, '*'))
|
---|
| 507 | wipeallf("%s\\*", dir);
|
---|
| 508 | DosError(FERR_DISABLEHARDERR);
|
---|
| 509 | if (DosDeleteDir(dir)) {
|
---|
| 510 | make_deleteable(dir);
|
---|
| 511 | DosDeleteDir(dir);
|
---|
| 512 | }
|
---|
| 513 | }
|
---|
| 514 | else if (IsFile(dir) > 0) {
|
---|
| 515 | DosError(FERR_DISABLEHARDERR);
|
---|
| 516 | if (DosForceDelete(dir)) {
|
---|
| 517 | make_deleteable(dir);
|
---|
| 518 | DosForceDelete(dir);
|
---|
| 519 | }
|
---|
| 520 | if (zaplong)
|
---|
| 521 | ZapLongName(dir);
|
---|
| 522 | Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(dir), MPVOID);
|
---|
| 523 | }
|
---|
[551] | 524 | }
|
---|
| 525 | }
|
---|
[1163] | 526 | else { /* different drives */
|
---|
[551] | 527 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 528 | ret = DosCopy(oldname, newname, DCPY_EXISTING); /* <=-NOTE! */
|
---|
[551] | 529 | if (ret == ERROR_DISK_CHANGE) {
|
---|
[1163] | 530 | DosError(FERR_ENABLEHARDERR);
|
---|
[1402] | 531 | ret = DosCopy(oldname, newname, DCPY_EXISTING);
|
---|
[1163] | 532 | diskchange = TRUE;
|
---|
[551] | 533 | }
|
---|
| 534 | if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
|
---|
[1402] | 535 | if (TruncName(newname, shortname)) { /* make 8.3 filename */
|
---|
[1163] | 536 | DosError(FERR_DISABLEHARDERR);
|
---|
| 537 | ret = DosCopy(oldname, shortname, DCPY_EXISTING);
|
---|
| 538 | if (!ret) { /* success -- write longname ea */
|
---|
[1402] | 539 | WriteLongName(shortname, newname);
|
---|
| 540 | strcpy(newname, shortname);
|
---|
[1163] | 541 | /* broadcast fixup msg to windows */
|
---|
| 542 | Broadcast((HAB) 0,
|
---|
| 543 | hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
|
---|
| 544 | }
|
---|
| 545 | }
|
---|
[551] | 546 | }
|
---|
| 547 | else if (!ret && *longname) {
|
---|
[2] | 548 |
|
---|
[1163] | 549 | CHAR fixname[CCHMAXPATH];
|
---|
[2] | 550 |
|
---|
[1402] | 551 | strcpy(fixname, newname);
|
---|
[1163] | 552 | p = strrchr(fixname, '\\');
|
---|
| 553 | if (p) {
|
---|
| 554 | p++;
|
---|
| 555 | *p = 0;
|
---|
| 556 | }
|
---|
| 557 | strcat(fixname, longname);
|
---|
| 558 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 559 | DosMove(newname, fixname);
|
---|
| 560 | strcpy(newname, fixname);
|
---|
[1163] | 561 | if (zaplong)
|
---|
| 562 | ZapLongName(fixname);
|
---|
| 563 | Broadcast((HAB) 0,
|
---|
| 564 | hwndMain, UM_UPDATERECORD, MPFROMP(fixname), MPVOID);
|
---|
[2] | 565 | }
|
---|
[1163] | 566 | if (!ret) { /* double-check success */
|
---|
| 567 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 568 | rc = DosQueryPathInfo(newname,
|
---|
[1163] | 569 | FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
|
---|
| 570 | if (rc == ERROR_DISK_CHANGE) {
|
---|
| 571 | DosError(FERR_ENABLEHARDERR);
|
---|
[1402] | 572 | rc = DosQueryPathInfo(newname,
|
---|
[1163] | 573 | FIL_STANDARDL, &st2, sizeof(FILESTATUS3L));
|
---|
| 574 | }
|
---|
| 575 | if (!rc && st2.cbFile == st.cbFile) { /* seems to have worked... */
|
---|
| 576 | DosError(FERR_DISABLEHARDERR);
|
---|
| 577 | if (diskchange) {
|
---|
| 578 | DosError(FERR_ENABLEHARDERR);
|
---|
| 579 | DosQueryPathInfo(oldname, FIL_STANDARDL, &dummy, sizeof(FILESTATUS3L)); /* force disk change */
|
---|
| 580 | }
|
---|
| 581 | if (!(st2.attrFile & FILE_DIRECTORY)) /* erase file */
|
---|
[1402] | 582 | unlinkf(oldname);
|
---|
[1163] | 583 | else { /* remove directory */
|
---|
| 584 | wipeallf("%s\\*", oldname);
|
---|
| 585 | DosError(FERR_DISABLEHARDERR);
|
---|
| 586 | if (DosDeleteDir(oldname)) {
|
---|
| 587 | make_deleteable(oldname);
|
---|
| 588 | DosDeleteDir(oldname);
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 | }
|
---|
[551] | 592 | }
|
---|
| 593 | }
|
---|
| 594 | return ret;
|
---|
[2] | 595 |
|
---|
[551] | 596 | case COPY:
|
---|
| 597 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 598 | ret = DosCopy(oldname, newname, DCPY_EXISTING); /* <=-NOTE! */
|
---|
[551] | 599 | if (ret == ERROR_DISK_CHANGE) {
|
---|
| 600 | DosError(FERR_ENABLEHARDERR);
|
---|
[1402] | 601 | ret = DosCopy(oldname, newname, DCPY_EXISTING);
|
---|
[551] | 602 | diskchange = TRUE;
|
---|
| 603 | }
|
---|
| 604 | if (ret == ERROR_INVALID_NAME || ret == ERROR_FILENAME_EXCED_RANGE) {
|
---|
[1402] | 605 | if (TruncName(newname, shortname)) {
|
---|
[1163] | 606 | DosError((diskchange) ? FERR_ENABLEHARDERR : FERR_DISABLEHARDERR);
|
---|
| 607 | ret = DosCopy(oldname, shortname, DCPY_EXISTING);
|
---|
| 608 | if (!ret) {
|
---|
[1402] | 609 | WriteLongName(shortname, newname);
|
---|
| 610 | strcpy(newname, shortname);
|
---|
[1163] | 611 | Broadcast((HAB) 0,
|
---|
| 612 | hwndMain, UM_UPDATERECORD, MPFROMP(shortname), MPVOID);
|
---|
| 613 | }
|
---|
[2] | 614 | }
|
---|
[551] | 615 | }
|
---|
| 616 | else if (!ret && *longname) {
|
---|
[2] | 617 |
|
---|
[551] | 618 | CHAR fixname[CCHMAXPATH];
|
---|
[2] | 619 |
|
---|
[1402] | 620 | strcpy(fixname, newname);
|
---|
[551] | 621 | p = strrchr(fixname, '\\');
|
---|
| 622 | if (p) {
|
---|
[1163] | 623 | p++;
|
---|
| 624 | *p = 0;
|
---|
[2] | 625 | }
|
---|
[551] | 626 | strcat(fixname, longname);
|
---|
| 627 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 628 | DosMove(newname, fixname);
|
---|
[551] | 629 | if (zaplong)
|
---|
[1163] | 630 | ZapLongName(fixname);
|
---|
[551] | 631 | Broadcast((HAB) 0, hwndMain, UM_UPDATERECORD, MPFROMP(fixname), MPVOID);
|
---|
| 632 | }
|
---|
| 633 | return ret;
|
---|
[2] | 634 |
|
---|
[1163] | 635 | default: /* shouldn't happen */
|
---|
[551] | 636 | Runtime_Error(pszSrcFile, __LINE__, "bad case %u", type);
|
---|
| 637 | break;
|
---|
[2] | 638 | }
|
---|
[1163] | 639 | return (APIRET) - 3; /* bad type */
|
---|
[2] | 640 | }
|
---|
| 641 |
|
---|
[551] | 642 | INT make_deleteable(CHAR * filename)
|
---|
[347] | 643 | {
|
---|
[2] | 644 | INT ret = -1;
|
---|
[847] | 645 | FILESTATUS3 fsi;
|
---|
[2] | 646 |
|
---|
| 647 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 648 | if (!DosQueryPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi))) {
|
---|
[2] | 649 | fsi.attrFile = 0;
|
---|
| 650 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 651 | if (!xDosSetPathInfo(filename, FIL_STANDARD, &fsi, sizeof(fsi), 0))
|
---|
[2] | 652 | ret = 0;
|
---|
| 653 | }
|
---|
| 654 | return ret;
|
---|
| 655 | }
|
---|
| 656 |
|
---|
[827] | 657 | INT wipeallf(CHAR *string, ...)
|
---|
[347] | 658 | {
|
---|
[2] | 659 | /* unlink everything from directory on down... */
|
---|
| 660 |
|
---|
[847] | 661 | FILEFINDBUF3 *f;
|
---|
[551] | 662 | HDIR search_handle;
|
---|
| 663 | ULONG num_matches;
|
---|
| 664 | CHAR *p, *ss, *str;
|
---|
| 665 | CHAR s[CCHMAXPATH], mask[257];
|
---|
| 666 | va_list ap;
|
---|
| 667 | INT rc;
|
---|
[2] | 668 |
|
---|
[551] | 669 | va_start(ap, string);
|
---|
| 670 | vsprintf(s, string, ap);
|
---|
[2] | 671 | va_end(ap);
|
---|
| 672 |
|
---|
[551] | 673 | if (!*s)
|
---|
[2] | 674 | return -1;
|
---|
| 675 | p = s;
|
---|
[551] | 676 | while ((p = strchr(p, '/')) != NULL) {
|
---|
[2] | 677 | *p = '\\';
|
---|
| 678 | p++;
|
---|
| 679 | }
|
---|
| 680 |
|
---|
[551] | 681 | str = xstrdup(s, pszSrcFile, __LINE__);
|
---|
| 682 | if (!str)
|
---|
[2] | 683 | return -1;
|
---|
| 684 |
|
---|
[1163] | 685 | { /* safety net -- disallow deleting a root dir or partial name */
|
---|
[2] | 686 | CHAR temp;
|
---|
| 687 |
|
---|
[551] | 688 | p = strrchr(str, '\\');
|
---|
| 689 | if (p) {
|
---|
[2] | 690 | p++;
|
---|
| 691 | temp = *p;
|
---|
| 692 | *p = 0;
|
---|
[551] | 693 | if (IsRoot(str) || !IsFullName(str)) {
|
---|
[1163] | 694 | /* under no circumstances! */
|
---|
| 695 | Runtime_Error(pszSrcFile, __LINE__, "bad name %s", str);
|
---|
| 696 | free(str);
|
---|
| 697 | return -1;
|
---|
[2] | 698 | }
|
---|
| 699 | *p = temp;
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 |
|
---|
| 703 | p = s;
|
---|
[1163] | 704 | p = strrchr(s, '\\'); /* strip s to just path */
|
---|
[551] | 705 | if (!p)
|
---|
| 706 | p = strrchr(s, ':');
|
---|
| 707 | if (p) {
|
---|
[2] | 708 | p++;
|
---|
[551] | 709 | strncpy(mask, p, 256);
|
---|
[2] | 710 | mask[256] = 0;
|
---|
| 711 | *p = 0;
|
---|
| 712 | }
|
---|
| 713 | else {
|
---|
| 714 | *mask = 0;
|
---|
| 715 | *s = 0;
|
---|
| 716 | }
|
---|
| 717 |
|
---|
[551] | 718 | ss = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
[847] | 719 | f = xmalloc(sizeof(FILEFINDBUF3), pszSrcFile, __LINE__);
|
---|
[347] | 720 | if (!ss || !f) {
|
---|
[1009] | 721 | xfree(ss, pszSrcFile, __LINE__);
|
---|
| 722 | xfree(f, pszSrcFile, __LINE__);
|
---|
[1039] | 723 | free(str);
|
---|
[2] | 724 | return -1;
|
---|
| 725 | }
|
---|
| 726 |
|
---|
| 727 | search_handle = HDIR_CREATE;
|
---|
[841] | 728 | num_matches = 1;
|
---|
[2] | 729 |
|
---|
| 730 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 731 | if (!DosFindFirst(str, &search_handle, FILE_NORMAL | FILE_DIRECTORY |
|
---|
[1163] | 732 | FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
|
---|
| 733 | f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
|
---|
[2] | 734 |
|
---|
[551] | 735 | strcpy(ss, s);
|
---|
[2] | 736 | p = &ss[strlen(ss)];
|
---|
| 737 |
|
---|
| 738 | do {
|
---|
[551] | 739 | strcpy(p, f->achName);
|
---|
| 740 | if (f->attrFile & FILE_DIRECTORY) {
|
---|
[1163] | 741 | if (strcmp(f->achName, ".") && strcmp(f->achName, "..")) {
|
---|
| 742 | wipeallf("%s/%s", ss, mask); /* recurse to wipe files */
|
---|
| 743 | DosError(FERR_DISABLEHARDERR);
|
---|
| 744 | if (DosDeleteDir(ss)) { /* remove directory */
|
---|
| 745 | make_deleteable(ss);
|
---|
| 746 | DosError(FERR_DISABLEHARDERR);
|
---|
| 747 | DosDeleteDir(ss);
|
---|
| 748 | }
|
---|
| 749 | }
|
---|
[2] | 750 | }
|
---|
| 751 | else {
|
---|
[1163] | 752 | DosError(FERR_DISABLEHARDERR);
|
---|
| 753 | if (DosForceDelete(ss)) {
|
---|
| 754 | make_deleteable(ss);
|
---|
| 755 | DosError(FERR_DISABLEHARDERR);
|
---|
| 756 | rc = (INT) DosForceDelete(ss);
|
---|
| 757 | if (rc)
|
---|
| 758 | return rc;
|
---|
| 759 | }
|
---|
[2] | 760 | }
|
---|
[847] | 761 | num_matches = 1;
|
---|
[2] | 762 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 763 | } while (!DosFindNext(search_handle, f, sizeof(FILEFINDBUF3),
|
---|
[1163] | 764 | &num_matches));
|
---|
[2] | 765 | DosFindClose(search_handle);
|
---|
| 766 | }
|
---|
| 767 |
|
---|
[1039] | 768 | free(f);
|
---|
| 769 | free(ss);
|
---|
| 770 | free(str);
|
---|
[2] | 771 | return 0;
|
---|
| 772 | }
|
---|
| 773 |
|
---|
[1193] | 774 | #if 0 // JBS 11 Sep 08
|
---|
[551] | 775 | INT unlink_allf(CHAR * string, ...)
|
---|
[347] | 776 | {
|
---|
[2] | 777 | /* wildcard delete */
|
---|
| 778 |
|
---|
[847] | 779 | FILEFINDBUF3 *f;
|
---|
[551] | 780 | HDIR search_handle;
|
---|
[2] | 781 | ULONG num_matches;
|
---|
[551] | 782 | CHAR *p, *ss, *str;
|
---|
| 783 | CHAR s[CCHMAXPATH];
|
---|
[2] | 784 | va_list ap;
|
---|
| 785 |
|
---|
[551] | 786 | va_start(ap, string);
|
---|
| 787 | vsprintf(s, string, ap);
|
---|
[2] | 788 | va_end(ap);
|
---|
| 789 |
|
---|
[551] | 790 | if (!*s)
|
---|
[2] | 791 | return -1;
|
---|
| 792 | p = s;
|
---|
[551] | 793 | while ((p = strchr(p, '/')) != NULL) {
|
---|
[2] | 794 | *p = '\\';
|
---|
| 795 | p++;
|
---|
| 796 | }
|
---|
| 797 |
|
---|
[551] | 798 | str = xstrdup(s, pszSrcFile, __LINE__);
|
---|
[347] | 799 | if (!str)
|
---|
[2] | 800 | return -1;
|
---|
| 801 |
|
---|
| 802 | p = s;
|
---|
[1163] | 803 | p = strrchr(s, '\\'); /* strip s to just path */
|
---|
[551] | 804 | if (!p)
|
---|
| 805 | p = strrchr(s, ':');
|
---|
| 806 | if (p) {
|
---|
[2] | 807 | p++;
|
---|
| 808 | *p = 0;
|
---|
| 809 | }
|
---|
| 810 | else
|
---|
| 811 | *s = 0;
|
---|
| 812 |
|
---|
[551] | 813 | ss = xmalloc(CCHMAXPATH, pszSrcFile, __LINE__);
|
---|
[847] | 814 | f = xmalloc(sizeof(FILEFINDBUF3), pszSrcFile, __LINE__);
|
---|
[347] | 815 | if (!ss || !f) {
|
---|
[1009] | 816 | xfree(ss, pszSrcFile, __LINE__);
|
---|
| 817 | xfree(f, pszSrcFile, __LINE__);
|
---|
[1039] | 818 | free(str);
|
---|
[2] | 819 | return -1;
|
---|
| 820 | }
|
---|
| 821 |
|
---|
| 822 | search_handle = HDIR_CREATE;
|
---|
[838] | 823 | num_matches = 1;
|
---|
[2] | 824 |
|
---|
| 825 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 826 | if (!DosFindFirst(str, &search_handle, FILE_NORMAL, f,
|
---|
[1163] | 827 | sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
|
---|
[2] | 828 |
|
---|
[551] | 829 | strcpy(ss, s);
|
---|
[2] | 830 | p = &ss[strlen(ss)];
|
---|
| 831 |
|
---|
| 832 | do {
|
---|
[551] | 833 | strcpy(p, f->achName);
|
---|
| 834 | unlinkf("%s", ss);
|
---|
[838] | 835 | num_matches = 1;
|
---|
[2] | 836 | DosError(FERR_DISABLEHARDERR);
|
---|
[847] | 837 | } while (!DosFindNext(search_handle, f, sizeof(FILEFINDBUF3),
|
---|
[1163] | 838 | &num_matches));
|
---|
[2] | 839 | DosFindClose(search_handle);
|
---|
| 840 | }
|
---|
| 841 |
|
---|
[1039] | 842 | free(f);
|
---|
| 843 | free(ss);
|
---|
| 844 | free(str);
|
---|
[2] | 845 | return 0;
|
---|
| 846 | }
|
---|
[1163] | 847 | #endif
|
---|
[2] | 848 |
|
---|
[1402] | 849 | INT unlinkf(CHAR *string)
|
---|
[347] | 850 | {
|
---|
[2] | 851 |
|
---|
[1402] | 852 | if (!strstr(string, ArcTempRoot)) {
|
---|
[2] | 853 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 854 | if (DosDelete(string)) {
|
---|
| 855 | make_deleteable(string);
|
---|
[2] | 856 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 857 | return DosDelete(string);
|
---|
[2] | 858 | }
|
---|
| 859 | }
|
---|
| 860 | else {
|
---|
| 861 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 862 | if (DosForceDelete(string)) {
|
---|
| 863 | make_deleteable(string);
|
---|
[2] | 864 | DosError(FERR_DISABLEHARDERR);
|
---|
[1402] | 865 | return DosForceDelete(string);
|
---|
[2] | 866 | }
|
---|
| 867 | }
|
---|
| 868 | return 0;
|
---|
| 869 | }
|
---|
[793] | 870 |
|
---|
| 871 | #pragma alloc_text(LONGNAMES,TruncName,GetLongName,WriteLongName)
|
---|
| 872 | #pragma alloc_text(LONGNAMES,ZapLongName,AdjustWildcardName)
|
---|
[1082] | 873 | #pragma alloc_text(COPYF,default_disk,docopyf,MakeTempName)
|
---|
[793] | 874 | #pragma alloc_text(UNLINKF,unlinkf,unlink_allf,make_deleteable,wipeallf)
|
---|