[48] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: valid.c 184 2005-06-05 19:00:32Z root $
|
---|
| 5 |
|
---|
| 6 | File name manipulation routines
|
---|
| 7 |
|
---|
[103] | 8 | Copyright (c) 1993, 1998 M. Kimes
|
---|
[184] | 9 | Copyright (c) 2002, 2005 Steven H.Levine
|
---|
[48] | 10 |
|
---|
[184] | 11 | 23 Nov 02 SHL RootName: rework for sanity
|
---|
| 12 | 27 Nov 02 SHL MakeFullName: correct typo
|
---|
| 13 | 11 Jun 03 SHL Add JFS and FAT32 support
|
---|
| 14 | 15 Jun 04 SHL Implement Jim Read's removable logic
|
---|
| 15 | 31 Jul 04 SHL Comments
|
---|
| 16 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 17 | 03 Jun 05 SHL Drop CD_DEBUG logic
|
---|
[48] | 18 |
|
---|
| 19 | ***********************************************************************/
|
---|
| 20 |
|
---|
[2] | 21 | #define INCL_DOS
|
---|
| 22 | #define INCL_WIN
|
---|
[103] | 23 | #define INCL_DOSDEVICES // DosDevIOCtl
|
---|
| 24 | #define INCL_DOSDEVIOCTL // DosDevIOCtl
|
---|
[2] | 25 |
|
---|
| 26 | #include <os2.h>
|
---|
| 27 | #include <stdlib.h>
|
---|
| 28 | #include <stdio.h>
|
---|
| 29 | #include <string.h>
|
---|
| 30 | #include <ctype.h>
|
---|
[103] | 31 |
|
---|
[2] | 32 | #include "fm3dll.h"
|
---|
| 33 |
|
---|
| 34 | #pragma alloc_text(VALID,CheckDrive,IsRoot,IsFile,IsFullName,needsquoting)
|
---|
| 35 | #pragma alloc_text(VALID,IsValidDir,IsValidDrive,MakeValidDir,IsVowel)
|
---|
| 36 | #pragma alloc_text(VALID,IsFileSame,IsNewer,TestDates,RootName,MakeFullName)
|
---|
| 37 | #pragma alloc_text(VALID,IsExecutable,IsBinary,IsDesktop,ParentIsDesktop)
|
---|
| 38 | #pragma alloc_text(FILLFLAGS,FillInDriveFlags,assign_ignores)
|
---|
| 39 | #pragma alloc_text(FILLFLAGS,ArgDriveFlags,DriveFlagsOne)
|
---|
| 40 | #pragma alloc_text(FINDDESK,GetDesktopName)
|
---|
| 41 |
|
---|
| 42 |
|
---|
[103] | 43 | APIRET MakeFullName (char *pszFileName)
|
---|
| 44 | {
|
---|
| 45 | /* pszFileName must be CCHMAXPATH long minimum! */
|
---|
[2] | 46 |
|
---|
[103] | 47 | char szPathName[CCHMAXPATH];
|
---|
[2] | 48 | APIRET rc;
|
---|
| 49 |
|
---|
| 50 | DosError(FERR_DISABLEHARDERR);
|
---|
[103] | 51 | rc = DosQueryPathInfo(pszFileName,
|
---|
| 52 | FIL_QUERYFULLNAME,
|
---|
| 53 | szPathName,
|
---|
| 54 | sizeof(szPathName));
|
---|
[48] | 55 | if(!rc)
|
---|
[103] | 56 | strcpy(pszFileName, szPathName); // Pass back actual name
|
---|
[2] | 57 | return rc;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 |
|
---|
[103] | 61 | char *RootName (char *filename)
|
---|
| 62 | {
|
---|
[2] | 63 | char *p = NULL,*pp;
|
---|
| 64 |
|
---|
[48] | 65 | // Return filename, strip path parts
|
---|
| 66 | // Return empty string when filename ends with \
|
---|
| 67 |
|
---|
[2] | 68 | if(filename) {
|
---|
| 69 | p = strrchr(filename,'\\');
|
---|
| 70 | pp = strrchr(filename,'/');
|
---|
| 71 | p = (p) ?
|
---|
[103] | 72 | (pp) ?
|
---|
| 73 | (p > pp) ?
|
---|
| 74 | p :
|
---|
| 75 | pp :
|
---|
| 76 | p :
|
---|
| 77 | pp;
|
---|
[2] | 78 | }
|
---|
| 79 | if(!p) /* name is itself a root */
|
---|
| 80 | p = filename;
|
---|
| 81 | else /* skip past backslash */
|
---|
| 82 | p++;
|
---|
| 83 | return p;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 |
|
---|
[103] | 87 | int TestDates (char *file1,char *file2)
|
---|
| 88 | {
|
---|
[2] | 89 | /*
|
---|
| 90 | * return 1 (file2 newer than file1),
|
---|
| 91 | * 0 (files same)
|
---|
| 92 | * or -1 (file1 newer than file2)
|
---|
| 93 | */
|
---|
| 94 |
|
---|
| 95 | int comp = 0;
|
---|
| 96 | FILESTATUS3 fs3o,fs3n;
|
---|
| 97 |
|
---|
| 98 | DosError(FERR_DISABLEHARDERR);
|
---|
| 99 | if(!DosQueryPathInfo(file1,
|
---|
[103] | 100 | FIL_STANDARD,
|
---|
| 101 | &fs3o,
|
---|
| 102 | sizeof(fs3o))) {
|
---|
[2] | 103 | DosError(FERR_DISABLEHARDERR);
|
---|
| 104 | if(!DosQueryPathInfo(file2,
|
---|
[103] | 105 | FIL_STANDARD,
|
---|
| 106 | &fs3n,
|
---|
| 107 | sizeof(fs3n))) {
|
---|
[2] | 108 | comp = (fs3n.fdateLastWrite.year >
|
---|
[103] | 109 | fs3o.fdateLastWrite.year) ? 1 :
|
---|
| 110 | (fs3n.fdateLastWrite.year <
|
---|
| 111 | fs3o.fdateLastWrite.year) ? -1 :
|
---|
| 112 | (fs3n.fdateLastWrite.month >
|
---|
| 113 | fs3o.fdateLastWrite.month) ? 1 :
|
---|
| 114 | (fs3n.fdateLastWrite.month <
|
---|
| 115 | fs3o.fdateLastWrite.month) ? -1 :
|
---|
| 116 | (fs3n.fdateLastWrite.day >
|
---|
| 117 | fs3o.fdateLastWrite.day) ? 1 :
|
---|
| 118 | (fs3n.fdateLastWrite.day <
|
---|
| 119 | fs3o.fdateLastWrite.day) ? -1 :
|
---|
| 120 | (fs3n.ftimeLastWrite.hours >
|
---|
| 121 | fs3o.ftimeLastWrite.hours) ? 1 :
|
---|
| 122 | (fs3n.ftimeLastWrite.hours <
|
---|
| 123 | fs3o.ftimeLastWrite.hours) ? -1 :
|
---|
| 124 | (fs3n.ftimeLastWrite.minutes >
|
---|
| 125 | fs3o.ftimeLastWrite.minutes) ? 1 :
|
---|
| 126 | (fs3n.ftimeLastWrite.minutes <
|
---|
| 127 | fs3o.ftimeLastWrite.minutes) ? -1 :
|
---|
| 128 | (fs3n.ftimeLastWrite.twosecs >
|
---|
| 129 | fs3o.ftimeLastWrite.twosecs) ? 1 :
|
---|
| 130 | (fs3n.ftimeLastWrite.twosecs <
|
---|
| 131 | fs3o.ftimeLastWrite.twosecs) ? -1 :
|
---|
| 132 | 0;
|
---|
[2] | 133 | }
|
---|
| 134 | }
|
---|
| 135 | return comp;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 |
|
---|
[103] | 139 | BOOL IsNewer (char *file1,char *file2)
|
---|
| 140 | {
|
---|
[2] | 141 | /* return TRUE if file2 is newer than file1 */
|
---|
| 142 |
|
---|
| 143 | return (TestDates(file1,file2) > 0);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 |
|
---|
[103] | 147 | BOOL IsDesktop (HAB hab,HWND hwnd)
|
---|
| 148 | {
|
---|
[2] | 149 | HWND hwndDesktop;
|
---|
| 150 |
|
---|
| 151 | if(hwnd == HWND_DESKTOP)
|
---|
| 152 | return TRUE;
|
---|
| 153 | hwndDesktop = WinQueryDesktopWindow(hab,NULLHANDLE);
|
---|
| 154 | if(hwnd == hwndDesktop)
|
---|
| 155 | return TRUE;
|
---|
| 156 | return FALSE;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
[103] | 159 | BOOL ParentIsDesktop (HWND hwnd,HWND hwndParent)
|
---|
| 160 | {
|
---|
[2] | 161 | HWND hwndDesktop;
|
---|
| 162 | BOOL ret = FALSE;
|
---|
| 163 |
|
---|
| 164 | if(!hwndParent)
|
---|
| 165 | hwndParent = WinQueryWindow(hwnd,QW_PARENT);
|
---|
| 166 | if(hwndParent == HWND_DESKTOP)
|
---|
| 167 | ret = TRUE;
|
---|
| 168 | else {
|
---|
| 169 | hwndDesktop = WinQueryDesktopWindow(WinQueryAnchorBlock(hwnd),(HWND)0);
|
---|
| 170 | if(hwndDesktop == hwndParent)
|
---|
| 171 | ret = TRUE;
|
---|
| 172 | }
|
---|
| 173 | return ret;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
[109] | 176 | /* CheckDrive
|
---|
| 177 | * @param chDrive drive letter
|
---|
| 178 | * @param pszFileSystem pointer to buffer to return file system type or NULL
|
---|
| 179 | * @param pulType pointer to long word to return drive flags or NULL
|
---|
| 180 | * @returns removability flag, 1 = removable, 0 = not removable, -1 = error
|
---|
| 181 | */
|
---|
[2] | 182 |
|
---|
[70] | 183 | INT CheckDrive (CHAR chDrive, CHAR *pszFileSystem, ULONG *pulType)
|
---|
| 184 | {
|
---|
[103] | 185 | CHAR szPath[3];
|
---|
| 186 | VOID *pvBuffer = NULL;
|
---|
| 187 | CHAR *pfsn;
|
---|
| 188 | CHAR *pfsd;
|
---|
| 189 | ULONG clBufferSize;
|
---|
| 190 | APIRET ulrc;
|
---|
| 191 | ULONG ulAction;
|
---|
| 192 | ULONG clParmBytes;
|
---|
| 193 | ULONG clDataBytes;
|
---|
| 194 | HFILE hDev;
|
---|
| 195 | # pragma pack(1)
|
---|
| 196 | struct {
|
---|
| 197 | BYTE Cmd;
|
---|
| 198 | BYTE Unit;
|
---|
| 199 | } parmPkt = {0, 0};
|
---|
| 200 | # define BPB_REMOVABLE_MEDIA 0x08 // 3 - Media is removable
|
---|
| 201 | struct
|
---|
| 202 | {
|
---|
| 203 | BIOSPARAMETERBLOCK bpb;
|
---|
| 204 | USHORT cCylinders; // Documented but not implemented
|
---|
| 205 | BYTE bDeviceType; // Documented but not implemented
|
---|
| 206 | USHORT fsDeviceAttr; // Documented but not implemented
|
---|
| 207 | } dataPkt;
|
---|
| 208 | # pragma pack()
|
---|
| 209 | BYTE NonRemovable;
|
---|
[2] | 210 | PFSQBUFFER2 pfsq;
|
---|
| 211 |
|
---|
[70] | 212 | if (pszFileSystem)
|
---|
| 213 | *pszFileSystem = 0;
|
---|
| 214 | if (pulType)
|
---|
| 215 | *pulType = 0;
|
---|
[2] | 216 |
|
---|
[103] | 217 | # define BUFFER_BYTES 4096
|
---|
| 218 | if(DosAllocMem(&pvBuffer,BUFFER_BYTES,
|
---|
| 219 | PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE)) {
|
---|
[2] | 220 | DosBeep(50,50);
|
---|
[70] | 221 | return -1; // Say failed
|
---|
[2] | 222 | }
|
---|
| 223 |
|
---|
[103] | 224 | szPath[0] = chDrive;
|
---|
| 225 | szPath[1] = ':';
|
---|
| 226 | szPath[2] = 0;
|
---|
| 227 | clBufferSize = BUFFER_BYTES;
|
---|
[2] | 228 | DosError(FERR_DISABLEHARDERR);
|
---|
[103] | 229 | ulrc = DosQueryFSAttach(szPath, 0, FSAIL_QUERYNAME,
|
---|
| 230 | (PFSQBUFFER2)pvBuffer, &clBufferSize);
|
---|
| 231 | if (ulrc)
|
---|
[70] | 232 | {
|
---|
| 233 | /* can't get any info at all */
|
---|
[103] | 234 | DosFreeMem(pvBuffer);
|
---|
[2] | 235 | DosError(FERR_DISABLEHARDERR);
|
---|
[70] | 236 | return -1; // Say failed
|
---|
[2] | 237 | }
|
---|
| 238 |
|
---|
[103] | 239 | pfsq = (PFSQBUFFER2)pvBuffer;
|
---|
[2] | 240 | pfsn = pfsq->szName + pfsq->cbName + 1;
|
---|
| 241 | pfsd = pfsn + pfsq->cbFSDName + 1;
|
---|
| 242 |
|
---|
[70] | 243 | if (pszFileSystem)
|
---|
| 244 | {
|
---|
| 245 | strncpy(pszFileSystem, pfsn, CCHMAXPATH);
|
---|
| 246 | pszFileSystem[CCHMAXPATH - 1] = 0;
|
---|
[2] | 247 | }
|
---|
| 248 |
|
---|
[70] | 249 | if (pulType && !strcmp(pfsn,CDFS))
|
---|
| 250 | *pulType |= DRIVE_NOTWRITEABLE | DRIVE_CDROM | DRIVE_REMOVABLE;
|
---|
[2] | 251 |
|
---|
[103] | 252 | if (((PFSQBUFFER2)pvBuffer)->iType == FSAT_REMOTEDRV)
|
---|
[70] | 253 | {
|
---|
| 254 | if (pulType)
|
---|
| 255 | *pulType |= DRIVE_REMOTE;
|
---|
| 256 | if (pulType && !strcmp(pfsn,CBSIFS))
|
---|
| 257 | {
|
---|
| 258 | *pulType |= DRIVE_ZIPSTREAM;
|
---|
| 259 | *pulType &= ~DRIVE_REMOTE;
|
---|
| 260 | *pulType |= DRIVE_NOLONGNAMES;
|
---|
| 261 | if (pfsq->cbFSAData)
|
---|
| 262 | {
|
---|
[103] | 263 | ULONG FType;
|
---|
[2] | 264 |
|
---|
[103] | 265 | if (CheckDrive(*pfsd,NULL,&FType) != -1)
|
---|
[70] | 266 | {
|
---|
[103] | 267 | if (FType & DRIVE_REMOVABLE)
|
---|
| 268 | *pulType |= DRIVE_REMOVABLE;
|
---|
| 269 | if (~FType & DRIVE_NOLONGNAMES)
|
---|
| 270 | *pulType &= ~DRIVE_NOLONGNAMES;
|
---|
| 271 | }
|
---|
[2] | 272 | }
|
---|
| 273 | }
|
---|
[70] | 274 | if (pulType &&
|
---|
[103] | 275 | (!strcmp(pfsn,HPFS) ||
|
---|
| 276 | !strcmp(pfsn,JFS) ||
|
---|
| 277 | !strcmp(pfsn,FAT32) ||
|
---|
| 278 | !strcmp(pfsn,HPFS386)))
|
---|
[70] | 279 | {
|
---|
| 280 | *pulType &= ~DRIVE_NOLONGNAMES;
|
---|
| 281 | }
|
---|
[103] | 282 | DosFreeMem(pvBuffer);
|
---|
| 283 | return 0; // Remotes are non-removable
|
---|
[2] | 284 | }
|
---|
| 285 |
|
---|
[70] | 286 | // Local drive
|
---|
| 287 | if (strcmp(pfsn,HPFS) &&
|
---|
| 288 | strcmp(pfsn,JFS) &&
|
---|
| 289 | strcmp(pfsn,CDFS) &&
|
---|
| 290 | strcmp(pfsn,FAT32) &&
|
---|
| 291 | strcmp(pfsn,HPFS386))
|
---|
| 292 | {
|
---|
| 293 | if(pulType)
|
---|
[103] | 294 | (*pulType) |= DRIVE_NOLONGNAMES; // Others can not have long names
|
---|
[2] | 295 | }
|
---|
| 296 |
|
---|
| 297 | DosError(FERR_DISABLEHARDERR);
|
---|
[103] | 298 | ulrc = DosOpen(szPath, &hDev, &ulAction, 0, 0, FILE_OPEN,
|
---|
| 299 | OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE |
|
---|
| 300 | OPEN_FLAGS_DASD | OPEN_FLAGS_FAIL_ON_ERROR, 0);
|
---|
| 301 | if(ulrc)
|
---|
[70] | 302 | {
|
---|
[2] | 303 | DosError(FERR_DISABLEHARDERR);
|
---|
[70] | 304 | if (pulType)
|
---|
| 305 | *pulType |= DRIVE_REMOVABLE; // Assume removable if can not access
|
---|
[103] | 306 | DosFreeMem(pvBuffer);
|
---|
[70] | 307 | return 1; // Say removable
|
---|
[2] | 308 | }
|
---|
[103] | 309 |
|
---|
| 310 | clParmBytes = sizeof(parmPkt.Cmd);
|
---|
| 311 | clDataBytes = sizeof(NonRemovable);
|
---|
| 312 | NonRemovable = 1; // Preset as non removable
|
---|
[2] | 313 | DosError(FERR_DISABLEHARDERR);
|
---|
[103] | 314 | ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE,
|
---|
| 315 | &parmPkt.Cmd, /* Address of the command-specific argument list. */
|
---|
| 316 | sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */
|
---|
| 317 | &clParmBytes, /* Pointer to the length of parameters. */
|
---|
| 318 | &NonRemovable, /* Address of the data area. */
|
---|
| 319 | sizeof(NonRemovable), /* Length, in bytes, of pData. */
|
---|
| 320 | &clDataBytes); /* Pointer to the length of data. */
|
---|
| 321 |
|
---|
| 322 | if (!ulrc && NonRemovable) {
|
---|
| 323 | // Could be USB so check BPB flags
|
---|
| 324 | clParmBytes = sizeof(parmPkt.Cmd);
|
---|
| 325 | clDataBytes = sizeof(dataPkt);
|
---|
| 326 | memset(&dataPkt, 0xff, sizeof(dataPkt));
|
---|
| 327 | DosError(FERR_DISABLEHARDERR);
|
---|
| 328 | ulrc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS,
|
---|
| 329 | &parmPkt.Cmd, /* Address of the command-specific argument list. */
|
---|
| 330 | sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */
|
---|
| 331 | &clParmBytes, /* Pointer to the length of parameters. */
|
---|
| 332 | &dataPkt, /* Address of the data area. */
|
---|
| 333 | sizeof(dataPkt), /* Length, in bytes, of pData. */
|
---|
| 334 | &clDataBytes); /* Pointer to the length of data. */
|
---|
| 335 |
|
---|
| 336 | if (!ulrc && (dataPkt.bpb.fsDeviceAttr & BPB_REMOVABLE_MEDIA))
|
---|
| 337 | NonRemovable = 0;
|
---|
| 338 | }
|
---|
| 339 |
|
---|
| 340 | DosClose(hDev);
|
---|
| 341 |
|
---|
[70] | 342 | if (!NonRemovable && pulType)
|
---|
| 343 | *pulType |= DRIVE_REMOVABLE;
|
---|
[103] | 344 |
|
---|
| 345 | DosFreeMem(pvBuffer);
|
---|
| 346 |
|
---|
[70] | 347 | return NonRemovable ? 0 : 1;
|
---|
[2] | 348 | }
|
---|
| 349 |
|
---|
| 350 |
|
---|
[103] | 351 | BOOL IsFileSame (CHAR *filename1,CHAR *filename2)
|
---|
| 352 | {
|
---|
[2] | 353 | /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */
|
---|
| 354 |
|
---|
| 355 | FILESTATUS3 fsa1,fsa2;
|
---|
| 356 | APIRET ret;
|
---|
| 357 |
|
---|
| 358 | if(filename1 && filename2) {
|
---|
| 359 | DosError(FERR_DISABLEHARDERR);
|
---|
| 360 | ret = DosQueryPathInfo(filename1,FIL_STANDARD,&fsa1,
|
---|
[103] | 361 | (ULONG)sizeof(fsa1));
|
---|
[2] | 362 | if(!ret) {
|
---|
| 363 | DosError(FERR_DISABLEHARDERR);
|
---|
| 364 | ret = DosQueryPathInfo(filename2,FIL_STANDARD,&fsa2,
|
---|
[103] | 365 | (ULONG)sizeof(fsa2));
|
---|
[2] | 366 | if(!ret) {
|
---|
[103] | 367 | if(fsa1.cbFile == fsa2.cbFile &&
|
---|
| 368 | (fsa1.attrFile & (~FILE_ARCHIVED)) ==
|
---|
| 369 | (fsa2.attrFile & (~FILE_ARCHIVED)))
|
---|
| 370 | return TRUE;
|
---|
[2] | 371 | }
|
---|
| 372 | }
|
---|
| 373 | }
|
---|
| 374 | return FALSE;
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 |
|
---|
[103] | 378 | INT IsFile (CHAR *filename)
|
---|
| 379 | {
|
---|
[2] | 380 | /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */
|
---|
| 381 |
|
---|
| 382 | FILESTATUS3 fsa;
|
---|
| 383 | APIRET ret;
|
---|
| 384 |
|
---|
| 385 | if(filename && *filename) {
|
---|
| 386 | DosError(FERR_DISABLEHARDERR);
|
---|
| 387 | ret = DosQueryPathInfo(filename,
|
---|
[103] | 388 | FIL_STANDARD,
|
---|
| 389 | &fsa,
|
---|
| 390 | (ULONG)sizeof(fsa));
|
---|
[2] | 391 | if(!ret)
|
---|
| 392 | return ((fsa.attrFile & FILE_DIRECTORY) == 0);
|
---|
| 393 | else if(IsValidDrive(*filename) && IsRoot(filename))
|
---|
| 394 | return 0;
|
---|
| 395 | }
|
---|
| 396 | return -1; /* error; doesn't exist or can't read or null filename */
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 |
|
---|
[103] | 400 | BOOL IsFullName (CHAR *filename)
|
---|
| 401 | {
|
---|
[2] | 402 | return (filename) ?
|
---|
[103] | 403 | (isalpha(*filename) && filename[1] == ':' && filename[2] == '\\') :
|
---|
| 404 | 0;
|
---|
[2] | 405 | }
|
---|
| 406 |
|
---|
| 407 |
|
---|
[103] | 408 | BOOL IsRoot (CHAR *filename)
|
---|
| 409 | {
|
---|
[2] | 410 | return (filename && isalpha(*filename) && filename[1] == ':' &&
|
---|
[103] | 411 | filename[2] == '\\' && !filename[3]);
|
---|
[2] | 412 | }
|
---|
| 413 |
|
---|
| 414 |
|
---|
[103] | 415 | BOOL IsValidDir (CHAR *path)
|
---|
| 416 | {
|
---|
[2] | 417 | CHAR fullname[CCHMAXPATH];
|
---|
| 418 | FILESTATUS3 fs;
|
---|
| 419 |
|
---|
| 420 | if(path) {
|
---|
| 421 | DosError(FERR_DISABLEHARDERR);
|
---|
| 422 | if(!DosQueryPathInfo(path,
|
---|
[103] | 423 | FIL_QUERYFULLNAME,
|
---|
| 424 | fullname,
|
---|
| 425 | sizeof(fullname))) {
|
---|
[2] | 426 | if(IsValidDrive(*fullname)) {
|
---|
[103] | 427 | if(!IsRoot(fullname)) {
|
---|
| 428 | DosError(FERR_DISABLEHARDERR);
|
---|
| 429 | if(!DosQueryPathInfo(fullname,
|
---|
| 430 | FIL_STANDARD,
|
---|
| 431 | &fs,
|
---|
| 432 | sizeof(fs)) &&
|
---|
| 433 | (fs.attrFile & FILE_DIRECTORY))
|
---|
| 434 | return TRUE;
|
---|
| 435 | }
|
---|
| 436 | else
|
---|
| 437 | return TRUE;
|
---|
[2] | 438 | }
|
---|
| 439 | }
|
---|
| 440 | }
|
---|
| 441 | return FALSE;
|
---|
| 442 | }
|
---|
| 443 |
|
---|
| 444 |
|
---|
[103] | 445 | BOOL IsValidDrive (CHAR drive)
|
---|
| 446 | {
|
---|
[2] | 447 | CHAR Path[] = " :",Buffer[256];
|
---|
| 448 | APIRET Status;
|
---|
| 449 | ULONG Size;
|
---|
| 450 | ULONG ulDriveNum,ulDriveMap;
|
---|
| 451 |
|
---|
| 452 | if(!isalpha(drive) ||
|
---|
| 453 | (driveflags[toupper(drive) - 'A'] & (DRIVE_IGNORE | DRIVE_INVALID)))
|
---|
| 454 | return FALSE;
|
---|
| 455 | DosError(FERR_DISABLEHARDERR);
|
---|
| 456 | Status = DosQCurDisk(&ulDriveNum,&ulDriveMap);
|
---|
| 457 | if(!Status) {
|
---|
| 458 | if(!(ulDriveMap & (1L << (ULONG)(toupper(drive) - 'A'))))
|
---|
| 459 | return FALSE;
|
---|
| 460 | Path[0] = toupper(drive);
|
---|
| 461 | Size = sizeof(Buffer);
|
---|
| 462 | DosError(FERR_DISABLEHARDERR);
|
---|
| 463 | Status = DosQueryFSAttach(Path,
|
---|
[103] | 464 | 0,
|
---|
| 465 | FSAIL_QUERYNAME,
|
---|
| 466 | (PFSQBUFFER2)Buffer,
|
---|
| 467 | &Size);
|
---|
[2] | 468 | }
|
---|
| 469 | return (Status == 0);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 |
|
---|
[103] | 473 | CHAR * MakeValidDir (CHAR *path)
|
---|
| 474 | {
|
---|
[2] | 475 | CHAR fullname[CCHMAXPATH],drive;
|
---|
| 476 | register CHAR *p;
|
---|
| 477 | FILESTATUS3 fs;
|
---|
| 478 | APIRET status;
|
---|
| 479 |
|
---|
| 480 | if(!MakeFullName(path)) {
|
---|
| 481 | if(IsValidDrive(*path)) {
|
---|
| 482 | for(;;) {
|
---|
[103] | 483 | if(IsRoot(path))
|
---|
| 484 | return path;
|
---|
| 485 | DosError(FERR_DISABLEHARDERR);
|
---|
| 486 | status = DosQueryPathInfo(path,
|
---|
| 487 | FIL_STANDARD,
|
---|
| 488 | &fs,
|
---|
| 489 | sizeof(fs));
|
---|
| 490 | if(!status &&
|
---|
| 491 | (fs.attrFile & FILE_DIRECTORY) != 0)
|
---|
| 492 | return path;
|
---|
| 493 | p = strrchr(path,'\\');
|
---|
| 494 | if(p) {
|
---|
| 495 | if(p < path + 3)
|
---|
| 496 | p++;
|
---|
| 497 | *p = 0;
|
---|
| 498 | }
|
---|
| 499 | else
|
---|
| 500 | break;
|
---|
[2] | 501 | }
|
---|
| 502 | }
|
---|
| 503 | }
|
---|
| 504 | DosError(FERR_DISABLEHARDERR);
|
---|
| 505 | if(!DosQuerySysInfo(QSV_BOOT_DRIVE,
|
---|
[103] | 506 | QSV_BOOT_DRIVE,
|
---|
| 507 | &drive,
|
---|
| 508 | 1L)) {
|
---|
[2] | 509 | drive += '@';
|
---|
| 510 | if(drive < 'C')
|
---|
| 511 | drive = 'C';
|
---|
| 512 | strcpy(path," :\\");
|
---|
| 513 | *path = drive;
|
---|
| 514 | }
|
---|
| 515 | else
|
---|
| 516 | save_dir2(path);
|
---|
| 517 | return path;
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 |
|
---|
[103] | 521 | BOOL IsExecutable (CHAR *filename)
|
---|
| 522 | {
|
---|
[2] | 523 | register CHAR *p;
|
---|
| 524 | APIRET ret;
|
---|
| 525 | ULONG apptype;
|
---|
| 526 |
|
---|
| 527 | if(filename) {
|
---|
| 528 | DosError(FERR_DISABLEHARDERR);
|
---|
| 529 | p = strrchr(filename,'.');
|
---|
| 530 | if(p)
|
---|
| 531 | ret = DosQAppType(filename,
|
---|
[103] | 532 | &apptype);
|
---|
[2] | 533 | else {
|
---|
| 534 |
|
---|
| 535 | char fname[CCHMAXPATH + 2];
|
---|
| 536 |
|
---|
| 537 | strcpy(fname,filename);
|
---|
| 538 | strcat(fname,".");
|
---|
| 539 | ret = DosQAppType(fname,
|
---|
[103] | 540 | &apptype);
|
---|
[2] | 541 | }
|
---|
| 542 | if((!ret && (!apptype ||
|
---|
[103] | 543 | (apptype &
|
---|
| 544 | (FAPPTYP_NOTWINDOWCOMPAT |
|
---|
| 545 | FAPPTYP_WINDOWCOMPAT |
|
---|
| 546 | FAPPTYP_WINDOWAPI |
|
---|
| 547 | FAPPTYP_BOUND |
|
---|
| 548 | FAPPTYP_DOS |
|
---|
| 549 | FAPPTYP_WINDOWSREAL |
|
---|
| 550 | FAPPTYP_WINDOWSPROT |
|
---|
| 551 | FAPPTYP_32BIT |
|
---|
| 552 | 0x1000)))) ||
|
---|
[2] | 553 | (p &&
|
---|
[103] | 554 | (!stricmp(p,".CMD") ||
|
---|
| 555 | !stricmp(p,".BAT"))))
|
---|
[2] | 556 | return TRUE;
|
---|
| 557 | }
|
---|
| 558 | return FALSE;
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 |
|
---|
[103] | 562 | VOID ArgDriveFlags (INT argc,CHAR **argv)
|
---|
| 563 | {
|
---|
[2] | 564 | INT x;
|
---|
| 565 |
|
---|
| 566 | for(x = 1;x < argc;x++) {
|
---|
| 567 | if(*argv[x] == '/' && isalpha(argv[x][1])) {
|
---|
| 568 |
|
---|
| 569 | CHAR *p = &argv[x][1];
|
---|
| 570 |
|
---|
| 571 | while(isalpha(*p)) {
|
---|
[103] | 572 | driveflags[toupper(*p) - 'A'] |= DRIVE_IGNORE;
|
---|
| 573 | p++;
|
---|
[2] | 574 | }
|
---|
| 575 | }
|
---|
| 576 | else if(*argv[x] == ';' && isalpha(argv[x][1])) {
|
---|
| 577 |
|
---|
| 578 | CHAR *p = &argv[x][1];
|
---|
| 579 |
|
---|
| 580 | while(isalpha(*p)) {
|
---|
[103] | 581 | driveflags[toupper(*p) - 'A'] |= DRIVE_NOPRESCAN;
|
---|
| 582 | p++;
|
---|
[2] | 583 | }
|
---|
| 584 | }
|
---|
| 585 | else if(*argv[x] == ',' && isalpha(argv[x][1])) {
|
---|
| 586 |
|
---|
| 587 | CHAR *p = &argv[x][1];
|
---|
| 588 |
|
---|
| 589 | while(isalpha(*p)) {
|
---|
[103] | 590 | driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADICONS;
|
---|
| 591 | p++;
|
---|
[2] | 592 | }
|
---|
| 593 | }
|
---|
| 594 | else if(*argv[x] == '`' && isalpha(argv[x][1])) {
|
---|
| 595 |
|
---|
| 596 | CHAR *p = &argv[x][1];
|
---|
| 597 |
|
---|
| 598 | while(isalpha(*p)) {
|
---|
[103] | 599 | driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADSUBJS;
|
---|
| 600 | p++;
|
---|
[2] | 601 | }
|
---|
| 602 | }
|
---|
| 603 | else if(*argv[x] == '\'' && isalpha(argv[x][1])) {
|
---|
| 604 |
|
---|
| 605 | CHAR *p = &argv[x][1];
|
---|
| 606 |
|
---|
| 607 | while(isalpha(*p)) {
|
---|
[103] | 608 | driveflags[toupper(*p) - 'A'] |= DRIVE_NOLOADLONGS;
|
---|
| 609 | p++;
|
---|
[2] | 610 | }
|
---|
| 611 | }
|
---|
| 612 | }
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 |
|
---|
[70] | 616 | VOID DriveFlagsOne (INT x)
|
---|
| 617 | {
|
---|
[2] | 618 | INT removable;
|
---|
| 619 | CHAR szDrive[] = " :\\",FileSystem[CCHMAXPATH];
|
---|
| 620 | ULONG drvtype;
|
---|
| 621 |
|
---|
| 622 | *szDrive = (CHAR)(x + 'A');
|
---|
| 623 | *FileSystem = 0;
|
---|
| 624 | drvtype = 0;
|
---|
| 625 | removable = CheckDrive(*szDrive,FileSystem,&drvtype);
|
---|
| 626 | driveserial[x] = -1;
|
---|
| 627 | driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
|
---|
[103] | 628 | DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
|
---|
| 629 | DRIVE_INCLUDEFILES | DRIVE_SLOW);
|
---|
[70] | 630 | if(removable != -1)
|
---|
| 631 | {
|
---|
| 632 | struct
|
---|
| 633 | {
|
---|
[2] | 634 | ULONG serial;
|
---|
| 635 | CHAR volumelength;
|
---|
| 636 | CHAR volumelabel[CCHMAXPATH];
|
---|
| 637 | } volser;
|
---|
| 638 |
|
---|
| 639 | DosError(FERR_DISABLEHARDERR);
|
---|
| 640 | if(!DosQueryFSInfo((ULONG)x + 1,FSIL_VOLSER,&volser,sizeof(volser)))
|
---|
| 641 | driveserial[x] = volser.serial;
|
---|
| 642 | else
|
---|
| 643 | DosError(FERR_DISABLEHARDERR);
|
---|
| 644 | }
|
---|
| 645 | else
|
---|
| 646 | driveflags[x] |= DRIVE_INVALID;
|
---|
| 647 | driveflags[x] |= ((removable == -1 || removable == 1) ?
|
---|
[103] | 648 | DRIVE_REMOVABLE : 0);
|
---|
[2] | 649 | if(drvtype & DRIVE_REMOTE)
|
---|
| 650 | driveflags[x] |= DRIVE_REMOTE;
|
---|
[70] | 651 | if (strcmp(FileSystem,HPFS) &&
|
---|
| 652 | strcmp(FileSystem,JFS) &&
|
---|
| 653 | strcmp(FileSystem,CDFS) &&
|
---|
| 654 | strcmp(FileSystem,FAT32) &&
|
---|
| 655 | strcmp(FileSystem,HPFS386))
|
---|
| 656 | {
|
---|
[2] | 657 | driveflags[x] |= DRIVE_NOLONGNAMES;
|
---|
[70] | 658 | }
|
---|
[2] | 659 | if(!strcmp(FileSystem,CDFS)) {
|
---|
| 660 | removable = 1;
|
---|
| 661 | driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOTWRITEABLE |
|
---|
[103] | 662 | DRIVE_CDROM);
|
---|
[2] | 663 | }
|
---|
| 664 | else if(!stricmp(FileSystem,CBSIFS)) {
|
---|
| 665 | driveflags[x] |= DRIVE_ZIPSTREAM;
|
---|
| 666 | driveflags[x] &= (~DRIVE_REMOTE);
|
---|
| 667 | if(drvtype & DRIVE_REMOVABLE)
|
---|
| 668 | driveflags[x] |= DRIVE_REMOVABLE;
|
---|
| 669 | if(!(drvtype & DRIVE_NOLONGNAMES))
|
---|
| 670 | driveflags[x] &= (~DRIVE_NOLONGNAMES);
|
---|
| 671 | }
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 |
|
---|
[103] | 675 | VOID FillInDriveFlags (VOID *dummy)
|
---|
| 676 | {
|
---|
[2] | 677 | ULONG ulDriveNum,ulDriveMap;
|
---|
| 678 | register INT x;
|
---|
| 679 |
|
---|
| 680 | for(x = 0;x < 26;x++)
|
---|
| 681 | driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
|
---|
[103] | 682 | DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
|
---|
| 683 | DRIVE_INCLUDEFILES | DRIVE_SLOW);
|
---|
[2] | 684 | memset(driveserial,-1,sizeof(driveserial));
|
---|
| 685 | DosError(FERR_DISABLEHARDERR);
|
---|
| 686 | DosQCurDisk(&ulDriveNum,&ulDriveMap);
|
---|
| 687 | for(x = 0;x < 26;x++) {
|
---|
| 688 | if(ulDriveMap & (1L << x) && !(driveflags[x] & DRIVE_IGNORE)) {
|
---|
| 689 | {
|
---|
[103] | 690 | CHAR s[80];
|
---|
| 691 | ULONG flags = 0,size = sizeof(ULONG);
|
---|
[2] | 692 |
|
---|
[103] | 693 | sprintf(s,"%c.DriveFlags",(CHAR)(x + 'A'));
|
---|
| 694 | if(PrfQueryProfileData(fmprof,appname,s,&flags,&size) &&
|
---|
| 695 | size == sizeof(ULONG))
|
---|
| 696 | driveflags[x] |= flags;
|
---|
[2] | 697 | }
|
---|
| 698 |
|
---|
| 699 | if(x > 1) {
|
---|
[103] | 700 | if(!(driveflags[x] & DRIVE_NOPRESCAN))
|
---|
| 701 | DriveFlagsOne(x);
|
---|
| 702 | else
|
---|
| 703 | driveserial[x] = -1;
|
---|
[2] | 704 | }
|
---|
| 705 | else {
|
---|
[103] | 706 | driveflags[x] |= (DRIVE_REMOVABLE | DRIVE_NOLONGNAMES);
|
---|
| 707 | driveserial[x] = -1;
|
---|
[2] | 708 | }
|
---|
| 709 | }
|
---|
| 710 | else if(!(ulDriveMap & (1L << x)))
|
---|
| 711 | driveflags[x] |= DRIVE_INVALID;
|
---|
| 712 | }
|
---|
| 713 | {
|
---|
| 714 | ULONG startdrive = 3L;
|
---|
| 715 |
|
---|
| 716 | DosError(FERR_DISABLEHARDERR);
|
---|
| 717 | DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,
|
---|
[103] | 718 | (PVOID)&startdrive,(ULONG)sizeof(ULONG));
|
---|
[2] | 719 | if(startdrive)
|
---|
| 720 | driveflags[startdrive - 1] |= DRIVE_BOOT;
|
---|
| 721 | }
|
---|
| 722 | }
|
---|
| 723 |
|
---|
| 724 |
|
---|
[103] | 725 | CHAR * assign_ignores (CHAR *s)
|
---|
| 726 | {
|
---|
[2] | 727 | register INT x;
|
---|
| 728 | register CHAR *p,*pp;
|
---|
| 729 |
|
---|
| 730 | *s = '/';
|
---|
| 731 | s[1] = 0;
|
---|
| 732 | p = s + 1;
|
---|
| 733 | if(s) {
|
---|
| 734 | for(x = 0;x < 26;x++) {
|
---|
| 735 | if((driveflags[x] & DRIVE_IGNORE) != 0) {
|
---|
[103] | 736 | *p = (CHAR)x + 'A';
|
---|
| 737 | p++;
|
---|
| 738 | *p = 0;
|
---|
[2] | 739 | }
|
---|
| 740 | }
|
---|
| 741 | }
|
---|
| 742 | if(!s[1]) {
|
---|
| 743 | *s = 0;
|
---|
| 744 | pp = s;
|
---|
| 745 | }
|
---|
| 746 | else {
|
---|
| 747 | pp = &s[strlen(s)];
|
---|
| 748 | *pp = ' ';
|
---|
| 749 | pp++;
|
---|
| 750 | }
|
---|
| 751 | *pp = ';';
|
---|
| 752 | pp[1] = 0;
|
---|
| 753 | p = pp + 1;
|
---|
| 754 | if(pp) {
|
---|
| 755 | for(x = 0;x < 26;x++) {
|
---|
| 756 | if((driveflags[x] & DRIVE_NOPRESCAN) != 0) {
|
---|
[103] | 757 | *p = (CHAR)x + 'A';
|
---|
| 758 | p++;
|
---|
| 759 | *p = 0;
|
---|
[2] | 760 | }
|
---|
| 761 | }
|
---|
| 762 | }
|
---|
| 763 | if(!pp[1])
|
---|
| 764 | *pp = 0;
|
---|
| 765 | pp = &s[strlen(s)];
|
---|
| 766 | *pp = ' ';
|
---|
| 767 | pp++;
|
---|
| 768 | *pp = ',';
|
---|
| 769 | pp[1] = 0;
|
---|
| 770 | p = pp + 1;
|
---|
| 771 | if(pp) {
|
---|
| 772 | for(x = 0;x < 26;x++) {
|
---|
| 773 | if((driveflags[x] & DRIVE_NOLOADICONS) != 0) {
|
---|
[103] | 774 | *p = (CHAR)x + 'A';
|
---|
| 775 | p++;
|
---|
| 776 | *p = 0;
|
---|
[2] | 777 | }
|
---|
| 778 | }
|
---|
| 779 | }
|
---|
| 780 | if(!pp[1])
|
---|
| 781 | *pp = 0;
|
---|
| 782 | pp = &s[strlen(s)];
|
---|
| 783 | *pp = ' ';
|
---|
| 784 | pp++;
|
---|
| 785 | *pp = '`';
|
---|
| 786 | pp[1] = 0;
|
---|
| 787 | p = pp + 1;
|
---|
| 788 | if(pp) {
|
---|
| 789 | for(x = 0;x < 26;x++) {
|
---|
| 790 | if((driveflags[x] & DRIVE_NOLOADSUBJS) != 0) {
|
---|
[103] | 791 | *p = (CHAR)x + 'A';
|
---|
| 792 | p++;
|
---|
| 793 | *p = 0;
|
---|
[2] | 794 | }
|
---|
| 795 | }
|
---|
| 796 | }
|
---|
| 797 | if(!pp[1])
|
---|
| 798 | *pp = 0;
|
---|
| 799 | pp = &s[strlen(s)];
|
---|
| 800 | *pp = ' ';
|
---|
| 801 | pp++;
|
---|
| 802 | *pp = '\'';
|
---|
| 803 | pp[1] = 0;
|
---|
| 804 | p = pp + 1;
|
---|
| 805 | if(pp) {
|
---|
| 806 | for(x = 0;x < 26;x++) {
|
---|
| 807 | if((driveflags[x] & DRIVE_NOLOADLONGS) != 0) {
|
---|
[103] | 808 | *p = (CHAR)x + 'A';
|
---|
| 809 | p++;
|
---|
| 810 | *p = 0;
|
---|
[2] | 811 | }
|
---|
| 812 | }
|
---|
| 813 | }
|
---|
| 814 | if(!pp[1])
|
---|
| 815 | *pp = 0;
|
---|
[123] | 816 | bstrip(s);
|
---|
[2] | 817 | return s;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 |
|
---|
[103] | 821 | BOOL needs_quoting (register CHAR *f)
|
---|
| 822 | {
|
---|
[2] | 823 | register CHAR *p = " &|<>";
|
---|
| 824 |
|
---|
| 825 | while(*p) {
|
---|
| 826 | if(strchr(f,*p))
|
---|
| 827 | return TRUE;
|
---|
| 828 | p++;
|
---|
| 829 | }
|
---|
| 830 | return FALSE;
|
---|
| 831 | }
|
---|
| 832 |
|
---|
| 833 |
|
---|
[103] | 834 | BOOL IsBinary (register CHAR *str,ULONG len)
|
---|
| 835 | {
|
---|
[2] | 836 | register ULONG x = 0L;
|
---|
| 837 |
|
---|
| 838 | if(str) {
|
---|
| 839 | while(x < len) {
|
---|
| 840 | if(str[x] < ' ' && str[x] != '\r' && str[x] != '\n' && str[x] != '\t' &&
|
---|
[103] | 841 | str[x] != '\x1b' && str[x] != '\x1a' && str[x] != '\07' &&
|
---|
| 842 | str[x] != '\x0c')
|
---|
| 843 | return TRUE;
|
---|
[2] | 844 | x++;
|
---|
| 845 | }
|
---|
| 846 | }
|
---|
| 847 | return FALSE;
|
---|
| 848 | }
|
---|
| 849 |
|
---|
| 850 |
|
---|
[103] | 851 | BOOL TestBinary (CHAR *filename)
|
---|
| 852 | {
|
---|
[2] | 853 | HFILE handle;
|
---|
[103] | 854 | ULONG ulAction;
|
---|
| 855 | ULONG len;
|
---|
| 856 | APIRET ulrc;
|
---|
[2] | 857 | CHAR buff[512];
|
---|
| 858 |
|
---|
| 859 | if(filename) {
|
---|
[103] | 860 | if(!DosOpen(filename,&handle,&ulAction,0L,0L,
|
---|
| 861 | OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
| 862 | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
|
---|
| 863 | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE |
|
---|
| 864 | OPEN_ACCESS_READONLY,0L)) {
|
---|
[2] | 865 | len = 512;
|
---|
[103] | 866 | ulrc = DosRead(handle,buff,len,&len);
|
---|
[2] | 867 | DosClose(handle);
|
---|
[103] | 868 | if(!ulrc && len)
|
---|
| 869 | return IsBinary(buff,len);
|
---|
[2] | 870 | }
|
---|
| 871 | }
|
---|
| 872 | return FALSE;
|
---|
| 873 | }
|
---|
| 874 |
|
---|
| 875 |
|
---|
[103] | 876 | char *IsVowel (char a)
|
---|
| 877 | {
|
---|
[2] | 878 | return (strchr("aeiouAEIOU",a) != NULL) ? "n" : NullStr;
|
---|
| 879 | }
|
---|
| 880 |
|
---|
| 881 |
|
---|
[103] | 882 | VOID GetDesktopName (CHAR *objectpath,ULONG size)
|
---|
| 883 | {
|
---|
[2] | 884 | PFN WQDPath;
|
---|
| 885 | HMODULE hmod = 0;
|
---|
[103] | 886 | APIRET ulrc;
|
---|
[2] | 887 | ULONG startdrive = 3L;
|
---|
| 888 | CHAR objerr[CCHMAXPATH];
|
---|
| 889 |
|
---|
| 890 | if(!objectpath)
|
---|
| 891 | return;
|
---|
| 892 | *objectpath = 0;
|
---|
| 893 | if(OS2ver[0] > 20 || (OS2ver[0] == 20 && OS2ver[1] >= 30)) {
|
---|
| 894 | /*
|
---|
| 895 | * if running under warp, we can get the desktop name
|
---|
| 896 | * this way...
|
---|
| 897 | */
|
---|
[103] | 898 | ulrc = DosLoadModule(objerr,
|
---|
| 899 | sizeof(objerr),
|
---|
| 900 | "PMWP",
|
---|
| 901 | &hmod);
|
---|
| 902 | if(!ulrc) {
|
---|
| 903 | ulrc = DosQueryProcAddr(hmod,
|
---|
| 904 | 262,
|
---|
| 905 | NULL,
|
---|
| 906 | &WQDPath);
|
---|
| 907 | if(!ulrc)
|
---|
| 908 | WQDPath(objectpath,size);
|
---|
[2] | 909 | DosFreeModule(hmod);
|
---|
| 910 | }
|
---|
| 911 | }
|
---|
| 912 | if(!*objectpath) {
|
---|
| 913 | if(!PrfQueryProfileString(HINI_SYSTEMPROFILE,
|
---|
[103] | 914 | "FolderWorkareaRunningObjects",
|
---|
| 915 | NULL,
|
---|
| 916 | "\0",
|
---|
| 917 | (PVOID)objectpath,
|
---|
| 918 | sizeof(objectpath)))
|
---|
[2] | 919 | *objectpath = 0;
|
---|
| 920 | if(!*objectpath || IsFile(objectpath)) {
|
---|
| 921 | DosBeep(250,10);
|
---|
| 922 | DosError(FERR_DISABLEHARDERR);
|
---|
| 923 | DosQuerySysInfo(QSV_BOOT_DRIVE,QSV_BOOT_DRIVE,
|
---|
[103] | 924 | (PVOID)&startdrive,(ULONG)sizeof(ULONG));
|
---|
[2] | 925 | sprintf(objectpath,
|
---|
[103] | 926 | "%c:\\DESKTOP",
|
---|
| 927 | ((CHAR)startdrive) + '@');
|
---|
[2] | 928 | }
|
---|
| 929 | }
|
---|
| 930 | }
|
---|