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