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