Changeset 135
- Timestamp:
- Jan 31, 2002, 11:12:45 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dosh.h
r133 r135 32 32 #ifndef DOSH_HEADER_INCLUDED 33 33 #define DOSH_HEADER_INCLUDED 34 35 /* ****************************************************************** 36 * 37 * Wrappers 38 * 39 ********************************************************************/ 40 41 // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h, 42 // all the following Dos* API calls are redirected to the dosh* 43 // counterparts 44 45 #ifdef DOSH_STANDARDWRAPPERS 46 47 #ifdef INCL_DOSPROCESS 48 49 APIRET XWPENTRY doshSleep(ULONG msec); 50 #define DosSleep(a) doshSleep((a)) 51 52 #endif 53 54 #ifdef INCL_DOSSEMAPHORES 55 56 APIRET XWPENTRY doshCreateMutexSem(PSZ pszName, 57 PHMTX phmtx, 58 ULONG flAttr, 59 BOOL32 fState); 60 #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d)) 61 62 APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout); 63 #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t)) 64 65 APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx); 66 #define DosReleaseMutexSem(h) doshReleaseMutexSem((h)) 67 68 #endif 69 70 #ifdef INCL_DOSEXCEPTIONS 71 72 APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec); 73 #define DosSetExceptionHandler(a) doshSetExceptionHandler((a)) 74 75 APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec); 76 #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a)) 77 78 #endif 79 80 #endif 34 81 35 82 /* ****************************************************************** … … 162 209 PBIOSPARAMETERBLOCK pdp); 163 210 164 BYTE doshQueryRemoveableType(PBIOSPARAMETERBLOCK pdp); 211 BYTE doshQueryDriveType(ULONG ulLogicalDrive, 212 PBIOSPARAMETERBLOCK pdp, 213 BOOL fFixed); 165 214 166 215 APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive, … … 185 234 #define DRVFL_MIXEDMODECD 0x0001 186 235 #define DRVFL_TOUCHFLOPPIES 0x0002 236 #define DRVFL_CHECKEAS 0x0004 237 #define DRVFL_CHECKLONGNAMES 0x0008 187 238 188 239 APIRET doshAssertDrive(ULONG ulLogicalDrive, … … 222 273 // 0x1a USHORT cCylinders; 223 274 // 0x1c BYTE bDeviceType; 224 // DEVTYPE_48TPI 0x0000 225 // DEVTYPE_96TPI 0x0001 226 // DEVTYPE_35 0x0002 227 // DEVTYPE_8SD 0x0003 228 // DEVTYPE_8DD 0x0004 229 // DEVTYPE_FIXED 0x0005 230 // DEVTYPE_TAPE 0x0006 231 // DEVTYPE_UNKNOWN 0x0007 275 #ifndef DEVTYPE_48TPI 276 #define DEVTYPE_48TPI 0x0000 277 #define DEVTYPE_96TPI 0x0001 278 #define DEVTYPE_35 0x0002 279 #define DEVTYPE_8SD 0x0003 280 #define DEVTYPE_8DD 0x0004 281 #define DEVTYPE_FIXED 0x0005 282 #define DEVTYPE_TAPE 0x0006 283 #endif 284 #define DEVTYPE_OTHER 0x0007 285 // includes 1.44 3.5" floppy 286 #define DEVTYPE_RWOPTICAL 0x0008 287 #define DEVTYPE_35_288MB 0x0009 232 288 // 0x1d USHORT fsDeviceAttr; 233 289 #define DEVATTR_REMOVEABLE 0x0001 … … 240 296 // addresses > 16 MB 241 297 #define DEVATTR_PARTITIONALREMOVEABLE 0x0008 298 // undocumented flag; set for ZIP drives 242 299 243 300 BYTE bType; 244 301 // do not change these codes, XWorkplace relies 245 302 // on them too to parse WPDisk data 246 #define DRVTYPE_HARDDISK 0247 #define DRVTYPE_FLOPPY 1248 #define DRVTYPE_TAPE 2249 #define DRVTYPE_VDISK 3250 #define DRVTYPE_CDROM 4251 #define DRVTYPE_LAN 5303 #define DRVTYPE_HARDDISK 0 304 #define DRVTYPE_FLOPPY 1 305 #define DRVTYPE_TAPE 2 306 #define DRVTYPE_VDISK 3 307 #define DRVTYPE_CDROM 4 308 #define DRVTYPE_LAN 5 252 309 #define DRVTYPE_PARTITIONABLEREMOVEABLE 6 253 #define DRVTYPE_UNKNOWN 255310 #define DRVTYPE_UNKNOWN 255 254 311 255 312 ULONG flDevice; … … 259 316 #define DFL_FIXED 0x0002 260 317 // drive is fixed; otherwise it is removeable! 318 // always set for harddisks and zip drives 261 319 #define DFL_PARTITIONABLEREMOVEABLE 0x0004 320 // set for zip drives; 262 321 // in that case, DFL_FIXED is set also 263 322 #define DFL_BOOTDRIVE 0x0008 … … 267 326 268 327 #define DFL_MEDIA_PRESENT 0x1000 269 // media is present in drive; always 270 // true for fixed and remove drives and 271 // drives A: and B: 328 // media is present in drive; 329 // -- always set for harddisks, 330 // unless the file system is not 331 // understood 332 // -- always set for remove drives 333 // -- always set for A: and B: 334 // -- set for CD-ROMS only if data 335 // CD-ROM is inserted 272 336 #define DFL_AUDIO_CD 0x2000 273 337 // set for CD-ROMs only, if an audio CD … … 276 340 #define DFL_SUPPORTS_EAS 0x4000 277 341 // drive supports extended attributes 342 // (assumption based on DosFSCtl, 343 // might not be correct for remote drives; 344 // reports correctly for FAT32 though) 278 345 #define DFL_SUPPORTS_LONGNAMES 0x8000 279 346 // drive supports long names; this does not … … 287 354 // e.g. "FAT" or "HPFS" or "JFS" or "CDFS" 288 355 289 BYTE bFileSystem;356 LONG lFileSystem; 290 357 // do not change these codes, XWorkplace relies 291 358 // on them too to parse WPDisk data 359 #define FSYS_UNKNOWN 0 360 // drive not formatted, or unknown file system 292 361 #define FSYS_FAT 1 293 362 #define FSYS_HPFS_JFS 2 294 363 #define FSYS_CDFS 3 295 #define FSYS_FAT32 8 // not used by WPS! 364 #define FSYS_TVFS 7 // not used by WPS! 365 #define FSYS_FAT32_EXT2 8 // not used by WPS! 296 366 #define FSYS_RAMFS 9 // not used by WPS! 297 367 #define FSYS_REMOTE 10 368 // NOTE: if this has a negative value, this is 369 // the APIRET code from DosQueryFSAttach 370 371 // error codes for various operations 372 APIRET arcIsFixedDisk, 373 arcQueryDiskParams, 374 arcQueryMedia, 375 arcOpenLongnames; 298 376 299 377 } XDISKINFO, *PXDISKINFO; … … 477 555 { 478 556 HFILE hf; 479 ULONG hmtx; // a HMTX really557 // ULONG hmtx; // a HMTX really 480 558 481 559 PSZ pszFilename; // as given to doshOpen … … 812 890 ********************************************************************/ 813 891 892 BOOL doshMatchCase(PCSZ pcszMask, 893 PCSZ pcszName); 894 814 895 BOOL doshMatch(PCSZ pcszMask, 815 896 PCSZ pcszName); -
trunk/include/helpers/winh.h
r127 r135 106 106 BOOL XWPENTRY winhSetDlgItemText(HWND hwnd, ULONG id, const char *pcsz); 107 107 #define WinSetDlgItemText(a,b,c) winhSetDlgItemText((a),(b),(c)) 108 109 #ifdef INCL_WINMESSAGEMGR 110 APIRET XWPENTRY winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout); 111 #define WinRequestMutexSem(a, b) winhRequestMutexSem((a), (b)) 112 #endif 108 113 #endif 109 114 -
trunk/src/helpers/dosh.c
r133 r135 49 49 #define INCL_DOSMODULEMGR 50 50 #define INCL_DOSPROCESS 51 #define INCL_DOSEXCEPTIONS 51 52 #define INCL_DOSSESMGR 52 53 #define INCL_DOSQUEUES … … 74 75 75 76 // static const CHAR G_acDriveLetters[28] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 77 78 /* 79 *@@category: Helpers\Control program helpers\Wrappers 80 */ 81 82 /* ****************************************************************** 83 * 84 * Wrappers 85 * 86 ********************************************************************/ 87 88 #ifdef DOSH_STANDARDWRAPPERS 89 90 /* 91 *@@ doshSleep: 92 * 93 *@@added V0.9.16 (2002-01-26) [umoeller] 94 */ 95 96 APIRET doshSleep(ULONG msec) 97 { 98 // put the call in brackets so the macro won't apply here 99 return (DosSleep)(msec); 100 } 101 102 /* 103 *@@ doshCreateMutexSem: 104 * 105 *@@added V0.9.16 (2002-01-26) [umoeller] 106 */ 107 108 APIRET doshCreateMutexSem(PSZ pszName, 109 PHMTX phmtx, 110 ULONG flAttr, 111 BOOL32 fState) 112 { 113 // put the call in brackets so the macro won't apply here 114 return (DosCreateMutexSem)(pszName, phmtx, flAttr, fState); 115 } 116 117 /* 118 *@@ doshRequestMutexSem: 119 * 120 *@@added V0.9.16 (2002-01-26) [umoeller] 121 */ 122 123 APIRET doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout) 124 { 125 return (DosRequestMutexSem)(hmtx, ulTimeout); 126 } 127 128 /* 129 *@@ doshReleaseMutexSem: 130 * 131 *@@added V0.9.16 (2002-01-26) [umoeller] 132 */ 133 134 APIRET doshReleaseMutexSem(HMTX hmtx) 135 { 136 return (DosReleaseMutexSem)(hmtx); 137 } 138 139 /* 140 *@@ doshSetExceptionHandler: 141 * 142 *@@added V0.9.16 (2002-01-26) [umoeller] 143 */ 144 145 APIRET doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec) 146 { 147 // put the call in brackets so the macro won't apply here 148 return (DosSetExceptionHandler)(pERegRec); 149 } 150 151 /* 152 *@@ doshUnsetExceptionHandler: 153 * 154 *@@added V0.9.16 (2002-01-26) [umoeller] 155 */ 156 157 APIRET doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec) 158 { 159 // put the call in brackets so the macro won't apply here 160 return (DosUnsetExceptionHandler)(pERegRec); 161 } 162 163 #endif 76 164 77 165 /* … … 427 515 * removeable disks. 428 516 * 517 * Returns: 518 * 519 * -- NO_ERROR: *pfFixed was set. 520 * 521 * -- ERROR_INVALID_DRIVE: drive letter invalid 522 * 523 * -- ERROR_NOT_SUPPORTED (50): for network drives. 524 * 429 525 *@@changed V0.9.14 (2001-08-03) [umoeller]: added extra fix for A: and B: 430 526 */ … … 555 651 556 652 /* 557 *@@ doshQuery RemoveableType:653 *@@ doshQueryDriveType: 558 654 * tests the specified BIOSPARAMETERBLOCK 559 655 * for whether it represents a CD-ROM or … … 562 658 * Returns one of: 563 659 * 564 * -- 0 660 * -- DRVTYPE_HARDDISK (0) 661 * 662 * -- DRVTYPE_PARTITIONABLEREMOVEABLE 565 663 * 566 664 * -- DRVTYPE_CDROM 567 665 * 568 * Call this only if doshIsFixedDisk 569 * returned FALSE. 666 * -- DRVTYPE_TAPE 667 * 668 * -- DRVTYPE_VDISK 669 * 670 * -- DRVTYPE_FLOPPY 671 * 672 * -- DRVTYPE_UNKNOWN (255) 570 673 * 571 674 * The BIOSPARAMETERBLOCK must be filled … … 575 678 */ 576 679 577 BYTE doshQueryRemoveableType(PBIOSPARAMETERBLOCK pdp) 680 BYTE doshQueryDriveType(ULONG ulLogicalDrive, 681 PBIOSPARAMETERBLOCK pdp, 682 BOOL fFixed) 578 683 { 579 684 if (pdp) 580 685 { 581 if ( (pdp->bDeviceType == 7) // "other" 582 && (pdp->usBytesPerSector == 2048) 583 && (pdp->usSectorsPerTrack == (USHORT)-1) 584 ) 585 return DRVTYPE_CDROM; 586 else if (pdp->fsDeviceAttr & DEVATTR_PARTITIONALREMOVEABLE) // 0x08 686 if (pdp->fsDeviceAttr & DEVATTR_PARTITIONALREMOVEABLE) // 0x08 587 687 return DRVTYPE_PARTITIONABLEREMOVEABLE; 588 else if (pdp->bDeviceType == 6) // tape 589 return DRVTYPE_TAPE; 590 } 591 592 return (0); 688 else if (fFixed) 689 return DRVTYPE_HARDDISK; 690 else if ( (pdp->bDeviceType == 7) // "other" 691 && (pdp->usBytesPerSector == 2048) 692 && (pdp->usSectorsPerTrack == (USHORT)-1) 693 ) 694 return DRVTYPE_CDROM; 695 else switch (pdp->bDeviceType) 696 { 697 case DEVTYPE_TAPE: // 6 698 return DRVTYPE_TAPE; 699 700 case DEVTYPE_48TPI: // 0, 360k 5.25" floppy 701 case DEVTYPE_96TPI: // 1, 1.2M 5.25" floppy 702 case DEVTYPE_35: // 2, 720k 3.5" floppy 703 case DEVTYPE_OTHER: // 7, 1.44 3.5" floppy 704 // 1.84M 3.5" floppy 705 case DEVTYPE_35_288MB: 706 if ( (ulLogicalDrive == 1) 707 || (ulLogicalDrive == 2) 708 ) 709 return DRVTYPE_FLOPPY; 710 else 711 return DRVTYPE_VDISK; 712 713 case DEVTYPE_RWOPTICAL: // 8, what is this?!? 714 return DRVTYPE_FLOPPY; 715 } 716 } 717 718 return (DRVTYPE_UNKNOWN); 593 719 } 594 720 … … 854 980 855 981 APIRET doshQueryMedia(ULONG ulLogicalDrive, 856 BOOL fCDROM, 982 BOOL fCDROM, // in: is drive CD-ROM? 857 983 ULONG fl) // in: DRVFL_* flags 858 984 { … … 978 1104 979 1105 if ( (!arc) 980 && (DRVTYPE_CDROM == doshQueryRemoveableType(&bpb)) 1106 && (DRVTYPE_CDROM == doshQueryDriveType(ulLogicalDrive, 1107 &bpb, 1108 fFixed)) 981 1109 ) 982 1110 { … … 1035 1163 * 1036 1164 * This function will not provoke "Drive not 1037 * ready" popups, hopefully. Tested with the 1038 * following drive types: 1039 * 1040 * -- all kinds of local partitions (FAT, 1041 * FAT32, HPFS, JFS) 1042 * 1043 * -- remote NetBIOS drives added via "net use" 1044 * 1045 * -- CD-ROM drives; one DVD drive and one 1046 * CD writer, even if no media is present 1165 * ready" popups, hopefully. 1047 1166 * 1048 1167 * fl can be any combination of the following: … … 1055 1174 * default values will be returned. 1056 1175 * 1176 * -- DRVFL_CHECKEAS: drive should always be 1177 * checked for EA support. If this is set, 1178 * we will call DosFSCtl for the non-well-known 1179 * file systems so we will always have a 1180 * value for the DFL_SUPPORTS_EAS flags. 1181 * Otherwise that flag might or might not 1182 * be set correctly. 1183 * 1184 * The EA support returned by DosFSCtl 1185 * might not be correct for remote file 1186 * systems since not all of them support 1187 * that query. 1188 * 1189 * -- DRVFL_CHECKLONGNAMES: drive should always be 1190 * checked for longname support. If this is 1191 * set, we will try a DosOpen on the drive 1192 * to see if it supports long filenames 1193 * (unless it's a "well-known" file-system 1194 * and we know it does). In enabled, the 1195 * DFL_SUPPORTS_LONGNAMES flag is reliable. 1196 * 1057 1197 * This should return only one of the following: 1058 *1059 * -- ERROR_INVALID_DRIVE: drive letter is invalid1060 *1061 * -- ERROR_DRIVE_LOCKED1062 1198 * 1063 1199 * -- NO_ERROR: disk info was filled, but not 1064 1200 * necessarily all info was available (e.g. 1065 1201 * if no media was present in CD-ROM drive). 1202 * See remarks below. 1203 * 1204 * -- ERROR_INVALID_DRIVE 15): ulLogicalDrive 1205 * is not used at all (invalid drive letter) 1206 * 1207 * -- ERROR_BAD_UNIT (20): if drive was renamed for 1208 * some reason (according to user reports 1209 * 1210 * -- ERROR_NOT_READY (21): for ZIP disks where 1211 * no media is inserted, depending on the 1212 * driver apparently... normally ZIP drive 1213 * letters should disappear when no media 1214 * is present 1215 * 1216 * -- ERROR_DRIVE_LOCKED (108) 1217 * 1218 * So in order to check whether a drive is present 1219 * and available, use this function as follows: 1220 * 1221 * 1) Call this function and check whether it 1222 * returns NO_ERROR for the given drive. 1223 * This will rule out invalid drive letters 1224 * and drives that are presently locked. 1225 * 1226 * 2) If so, check whether XDISKINFO.flDevice 1227 * has the DFL_MEDIA_PRESENT flag set. 1228 * This will rule out removeable drives without 1229 * media and unformatted hard disks. 1230 * 1231 * 3) If so, you can test the other fields if 1232 * you need more information. For example, 1233 * it would not be a good idea to create 1234 * a new file if the bType field is 1235 * DRVTYPE_CDROM. 1236 * 1237 * If you want to exclude removeable disks, 1238 * instead of checking bType, you should 1239 * rather check flDevice for the DFL_FIXED 1240 * flag, which will be set for ZIP drives also. 1241 * 1242 * Remarks for special drive types: 1243 * 1244 * -- Hard disks always have bType == DRVTYPE_HARDDISK. 1245 * For them, we always check the file system. 1246 * If this is reported as "UNKNOWN", this means 1247 * that the drive is unformatted or formatted 1248 * with a file system that OS/2 does not understand 1249 * (e.g. NTFS). Only in that case, flDevice 1250 * has the DFL_MEDIA_PRESENT bit clear. 1251 * 1252 * DFL_FIXED is always set. 1253 * 1254 * -- Remote (LAN) drives always have bType == DRVTYPE_LAN. 1255 * flDevice will always have the DFL_REMOTE and 1256 * DFL_MEDIA_PRESENT bits set. 1257 * 1258 * -- ZIP disks will have bType == DRVTYPE_PARTITIONABLEREMOVEABLE. 1259 * For them, flDevice will have both the 1260 * and DFL_PARTITIONABLEREMOVEABLE and DFL_FIXED 1261 * bits set. 1262 * 1263 * ZIP disks are a bit special because they are 1264 * dynamically mounted and unmounted when media 1265 * is inserted and removed. In other words, if 1266 * no media is present, the drive letter becomes 1267 * invalid. 1268 * 1269 * -- CD-ROM and DVD drives and CD writers will always 1270 * be reported as DRVTYPE_CDROM. The DFL_FIXED bit 1271 * will be clear always. For them, always check the 1272 * DFL_MEDIA_PRESENT present bit to avoid "Drive not 1273 * ready" popups. 1274 * 1275 * As a special goody, we can also determine if the 1276 * drive currently has audio media inserted (which 1277 * would provoke errors also), by setting the 1278 * DFL_AUDIO_CD bit. 1066 1279 * 1067 1280 *@@added V0.9.16 (2002-01-13) [umoeller] … … 1076 1289 HFILE hf; 1077 1290 ULONG dummy; 1078 BOOL fCheck = TRUE; 1291 BOOL fCheck = TRUE, 1292 fCheckFS = FALSE, 1293 fCheckLongnames = FALSE, 1294 fCheckEAs = FALSE; 1079 1295 1080 1296 memset(pdi, 0, sizeof(XDISKINFO)); … … 1100 1316 pdi->flDevice = DFL_MEDIA_PRESENT | DFL_SUPPORTS_EAS; 1101 1317 strcpy(pdi->szFileSystem, "FAT"); 1102 pdi-> bFileSystem = FSYS_FAT;1318 pdi->lFileSystem = FSYS_FAT; 1103 1319 } 1104 1320 } … … 1112 1328 &fFixed); 1113 1329 1114 if (arc == ERROR_INVALID_DRIVE) 1115 // drive letter doesn't exist at all: 1116 pdi->fPresent = FALSE; 1117 // return this APIRET 1118 else 1330 switch (arc) 1119 1331 { 1120 BOOL fCheckFS = FALSE; 1121 BOOL fCheckLongnames = FALSE; 1122 1123 if (fFixed) 1124 // fixed drive: 1125 pdi->flDevice |= DFL_FIXED | DFL_MEDIA_PRESENT; 1126 1127 if (!(arc = doshQueryDiskParams(ulLogicalDrive, 1128 &pdi->bpb))) 1129 { 1130 if (!fFixed) 1131 { 1132 // removeable: 1133 BYTE bTemp; 1134 if (bTemp = doshQueryRemoveableType(&pdi->bpb)) 1135 { 1136 // DRVTYPE_TAPE or DRVTYPE_CDROM 1137 pdi->bType = bTemp; 1138 1139 if (bTemp == DRVTYPE_PARTITIONABLEREMOVEABLE) 1140 pdi->flDevice |= DFL_FIXED 1141 | DFL_PARTITIONABLEREMOVEABLE; 1142 } 1143 1144 // before checking the drive, try if we have media 1145 if (!(arc = doshQueryMedia(ulLogicalDrive, 1146 (pdi->bType == DRVTYPE_CDROM), 1147 fl))) 1148 { 1149 pdi->flDevice |= DFL_MEDIA_PRESENT; 1150 fCheckFS = TRUE; 1151 fCheckLongnames = TRUE; 1152 } 1153 else if (arc == ERROR_AUDIO_CD_ROM) 1154 { 1155 pdi->flDevice |= DFL_AUDIO_CD; 1156 // do not check longnames and file-system 1157 } 1158 1159 arc = NO_ERROR; 1160 } 1161 else 1162 { 1163 pdi->bType = DRVTYPE_HARDDISK; 1164 fCheckFS = TRUE; 1165 } 1166 } 1167 else if (arc == ERROR_NOT_SUPPORTED) // 50 1168 { 1332 case ERROR_INVALID_DRIVE: 1333 // drive letter doesn't exist at all: 1334 pdi->fPresent = FALSE; 1335 // return this APIRET 1336 break; 1337 1338 case ERROR_NOT_SUPPORTED: // 50 for network drives 1169 1339 // we get this for remote drives added 1170 1340 // via "net use", so set these flags 1171 1341 pdi->bType = DRVTYPE_LAN; 1172 pdi-> bFileSystem = FSYS_REMOTE;1342 pdi->lFileSystem = FSYS_REMOTE; 1173 1343 pdi->flDevice |= DFL_REMOTE | DFL_MEDIA_PRESENT; 1174 1344 // but still check what file-system we … … 1176 1346 fCheckFS = TRUE; 1177 1347 fCheckLongnames = TRUE; 1178 } 1179 1180 if (fCheckFS) 1348 fCheckEAs = TRUE; 1349 break; 1350 1351 case NO_ERROR: 1181 1352 { 1182 // TRUE only for local fixed disks or 1183 // remote drives or if media was present above 1184 if (!(arc = doshQueryDiskFSType(ulLogicalDrive, 1185 pdi->szFileSystem, 1186 sizeof(pdi->szFileSystem)))) 1353 if (fFixed) 1187 1354 { 1188 if (!stricmp(pdi->szFileSystem, "FAT")) 1355 // fixed drive: 1356 pdi->flDevice |= DFL_FIXED | DFL_MEDIA_PRESENT; 1357 1358 fCheckFS = TRUE; 1359 fCheckLongnames = TRUE; 1360 fCheckEAs = TRUE; 1361 } 1362 1363 if (!(arc = doshQueryDiskParams(ulLogicalDrive, 1364 &pdi->bpb))) 1365 { 1366 BYTE bTemp = doshQueryDriveType(ulLogicalDrive, 1367 &pdi->bpb, 1368 fFixed); 1369 if (bTemp != DRVTYPE_UNKNOWN) 1189 1370 { 1190 pdi->bFileSystem = FSYS_FAT; 1191 pdi->flDevice |= DFL_SUPPORTS_EAS; 1192 fCheckLongnames = FALSE; 1371 // recognized: store it then 1372 pdi->bType = bTemp; 1373 1374 if (bTemp == DRVTYPE_PARTITIONABLEREMOVEABLE) 1375 pdi->flDevice |= DFL_FIXED 1376 | DFL_PARTITIONABLEREMOVEABLE; 1193 1377 } 1194 else if ( (!stricmp(pdi->szFileSystem, "HPFS")) 1195 || (!stricmp(pdi->szFileSystem, "JFS")) 1196 ) 1378 1379 if (!fFixed) 1197 1380 { 1198 pdi->bFileSystem = FSYS_HPFS_JFS; 1199 pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES; 1200 fCheckLongnames = FALSE; 1201 } 1202 else if (!stricmp(pdi->szFileSystem, "CDFS")) 1203 pdi->bFileSystem = FSYS_CDFS; 1204 else if (!stricmp(pdi->szFileSystem, "FAT32")) 1205 { 1206 pdi->bFileSystem = FSYS_FAT32; 1207 pdi->flDevice |= DFL_SUPPORTS_LONGNAMES; 1208 // @@todo check EA support 1209 fCheckLongnames = FALSE; 1210 } 1211 else if (!stricmp(pdi->szFileSystem, "RAMFS")) 1212 { 1213 pdi->bFileSystem = FSYS_RAMFS; 1214 pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES; 1215 fCheckLongnames = FALSE; 1381 // removeable: 1382 1383 // before checking the drive, try if we have media 1384 if (!(arc = doshQueryMedia(ulLogicalDrive, 1385 (pdi->bType == DRVTYPE_CDROM), 1386 fl))) 1387 { 1388 pdi->flDevice |= DFL_MEDIA_PRESENT; 1389 fCheckFS = TRUE; 1390 fCheckLongnames = TRUE; 1391 // but never EAs 1392 } 1393 else if (arc == ERROR_AUDIO_CD_ROM) 1394 { 1395 pdi->flDevice |= DFL_AUDIO_CD; 1396 // do not check longnames and file-system 1397 } 1398 else 1399 pdi->arcQueryMedia = arc; 1400 1401 arc = NO_ERROR; 1216 1402 } 1217 1403 } 1218 // else if this failed, we had an error popup!!1219 // shouldn't happen!!1404 else 1405 pdi->arcQueryDiskParams = arc; 1220 1406 } 1221 1222 if (fCheckLongnames) 1407 break; 1408 1409 default: 1410 pdi->arcIsFixedDisk = arc; 1411 // and return this 1412 break; 1413 1414 } // end swich arc = doshIsFixedDisk(ulLogicalDrive, &fFixed); 1415 } 1416 1417 if (fCheckFS) 1418 { 1419 // TRUE only for local fixed disks or 1420 // remote drives or if media was present above 1421 if (!(arc = doshQueryDiskFSType(ulLogicalDrive, 1422 pdi->szFileSystem, 1423 sizeof(pdi->szFileSystem)))) 1424 { 1425 if (!stricmp(pdi->szFileSystem, "UNKNOWN")) 1223 1426 { 1224 CHAR szTemp[30] = "?:\\long.name.file"; 1225 szTemp[0] = ulLogicalDrive + 'A' - 1; 1226 if (!(arc = DosOpen(szTemp, 1227 &hf, 1228 &dummy, 1229 0, 1230 0, 1231 FILE_READONLY, 1232 OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT, 1233 0))) 1234 { 1235 DosClose(hf); 1236 } 1237 1238 switch (arc) 1239 { 1240 case NO_ERROR: 1241 case ERROR_OPEN_FAILED: 1242 pdi->flDevice |= DFL_SUPPORTS_LONGNAMES; 1243 1244 // otherwise we get ERROR_INVALID_NAME 1245 // default: 1246 // printf(" drive %d returned %d\n", ulLogicalDrive, arc); 1247 } 1248 1249 arc = NO_ERROR; 1427 // this is returned by the stupid DosQueryFSAttach 1428 // if the file system is not recognized by OS/2, 1429 // or if the drive is unformatted 1430 pdi->lFileSystem = FSYS_UNKNOWN; 1431 pdi->flDevice &= ~DFL_MEDIA_PRESENT; 1432 fCheckLongnames = FALSE; 1433 fCheckEAs = FALSE; 1434 // should we return ERROR_NOT_DOS_DISK (26) 1435 // in this case? 1436 } 1437 else if (!stricmp(pdi->szFileSystem, "FAT")) 1438 { 1439 pdi->lFileSystem = FSYS_FAT; 1440 pdi->flDevice |= DFL_SUPPORTS_EAS; 1441 fCheckLongnames = FALSE; 1442 fCheckEAs = FALSE; 1443 } 1444 else if ( (!stricmp(pdi->szFileSystem, "HPFS")) 1445 || (!stricmp(pdi->szFileSystem, "JFS")) 1446 ) 1447 { 1448 pdi->lFileSystem = FSYS_HPFS_JFS; 1449 pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES; 1450 fCheckLongnames = FALSE; 1451 fCheckEAs = FALSE; 1452 } 1453 else if (!stricmp(pdi->szFileSystem, "CDFS")) 1454 pdi->lFileSystem = FSYS_CDFS; 1455 else if ( (!stricmp(pdi->szFileSystem, "FAT32")) 1456 || (!stricmp(pdi->szFileSystem, "ext2")) 1457 ) 1458 { 1459 pdi->lFileSystem = FSYS_FAT32_EXT2; 1460 fCheckLongnames = TRUE; 1461 fCheckEAs = TRUE; 1462 } 1463 else if (!stricmp(pdi->szFileSystem, "RAMFS")) 1464 { 1465 pdi->lFileSystem = FSYS_RAMFS; 1466 pdi->flDevice |= DFL_SUPPORTS_EAS | DFL_SUPPORTS_LONGNAMES; 1467 fCheckLongnames = FALSE; 1468 fCheckEAs = FALSE; 1469 } 1470 else if (!stricmp(pdi->szFileSystem, "TVFS")) 1471 { 1472 pdi->lFileSystem = FSYS_TVFS; 1473 fCheckLongnames = TRUE; 1474 fCheckEAs = TRUE; 1250 1475 } 1251 1476 } 1477 else 1478 // store negative error code 1479 pdi->lFileSystem = -(LONG)arc; 1480 } 1481 1482 if ( (!arc) 1483 && (fCheckLongnames) 1484 && (fl & DRVFL_CHECKLONGNAMES) 1485 ) 1486 { 1487 CHAR szTemp[30] = "?:\\long.name.file"; 1488 szTemp[0] = ulLogicalDrive + 'A' - 1; 1489 if (!(arc = DosOpen(szTemp, 1490 &hf, 1491 &dummy, 1492 0, 1493 0, 1494 FILE_READONLY, 1495 OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT, 1496 0))) 1497 { 1498 DosClose(hf); 1499 } 1500 1501 switch (arc) 1502 { 1503 case NO_ERROR: 1504 case ERROR_OPEN_FAILED: 1505 case ERROR_FILE_NOT_FOUND: // returned by TVFS 1506 pdi->flDevice |= DFL_SUPPORTS_LONGNAMES; 1507 break; 1508 1509 // if longnames are not supported, 1510 // we get ERROR_INVALID_NAME 1511 default: 1512 pdi->arcOpenLongnames = arc; 1513 break; 1514 1515 // default: 1516 // printf(" drive %d returned %d\n", ulLogicalDrive, arc); 1517 } 1518 1519 arc = NO_ERROR; 1520 } 1521 1522 if ( (!arc) 1523 && (fCheckEAs) 1524 && (fl & DRVFL_CHECKEAS) 1525 ) 1526 { 1527 EASIZEBUF easb = {0}; 1528 ULONG cbData = sizeof(easb), 1529 cbParams = 0; 1530 CHAR szDrive[] = "?:\\"; 1531 szDrive[0] = pdi->cDriveLetter; 1532 if (!(arc = DosFSCtl(&easb, 1533 cbData, 1534 &cbData, 1535 NULL, // params, 1536 cbParams, 1537 &cbParams, 1538 FSCTL_MAX_EASIZE, 1539 szDrive, 1540 -1, // HFILE 1541 FSCTL_PATHNAME))) 1542 if (easb.cbMaxEASize != 0) 1543 // the other field (cbMaxEAListSize) is 0 always, I think 1544 pdi->flDevice |= DFL_SUPPORTS_EAS; 1252 1545 } 1253 1546 … … 2127 2420 */ 2128 2421 2129 APIRET doshLockFile(PXFILE pFile)2422 /* APIRET doshLockFile(PXFILE pFile) 2130 2423 { 2131 2424 if (!pFile) … … 2140 2433 2141 2434 return (DosRequestMutexSem(pFile->hmtx, SEM_INDEFINITE_WAIT)); 2142 } 2435 } */ 2143 2436 2144 2437 /* … … 2148 2441 */ 2149 2442 2150 APIRET doshUnlockFile(PXFILE pFile)2443 /* APIRET doshUnlockFile(PXFILE pFile) 2151 2444 { 2152 2445 if (pFile) … … 2154 2447 2155 2448 return (ERROR_INVALID_PARAMETER); 2156 } 2449 } */ 2157 2450 2158 2451 /* … … 2198 2491 ULONG fl) // in: DRFL_* flags 2199 2492 { 2200 APIRET arc ;2493 APIRET arc = NO_ERROR; 2201 2494 ULONG cb = *pcb; 2202 2495 ULONG ulDummy; 2203 2496 2204 if (!(arc = doshLockFile(pFile))) // this checks for pFile2497 // if (!(arc = doshLockFile(pFile))) // this checks for pFile 2205 2498 { 2206 2499 *pcb = 0; … … 2357 2650 } 2358 2651 2359 doshUnlockFile(pFile);2652 // doshUnlockFile(pFile); 2360 2653 } 2361 2654 … … 2444 2737 2445 2738 if (!arc) 2446 if (!(arc = doshLockFile(pFile))) // this checks for pFile2739 // if (!(arc = doshLockFile(pFile))) // this checks for pFile 2447 2740 { 2448 2741 ULONG cbWritten; … … 2459 2752 } 2460 2753 2461 doshUnlockFile(pFile);2754 // doshUnlockFile(pFile); 2462 2755 } 2463 2756 … … 2484 2777 PCSZ pbData) // in: ptr to bytes to write (must be cb bytes) 2485 2778 { 2486 APIRET arc ;2487 if (!(arc = doshLockFile(pFile))) // this checks for pFile2779 APIRET arc = NO_ERROR; 2780 // if (!(arc = doshLockFile(pFile))) // this checks for pFile 2488 2781 { 2489 2782 ULONG cbWritten; … … 2503 2796 } 2504 2797 2505 doshUnlockFile(pFile);2798 // doshUnlockFile(pFile); 2506 2799 } 2507 2800 … … 2582 2875 // request the mutex so that we won't be 2583 2876 // taking the file away under someone's butt 2584 if (!(arc = doshLockFile(pFile)))2877 // if (!(arc = doshLockFile(pFile))) 2585 2878 { 2586 HMTX hmtx = pFile->hmtx;2587 pFile->hmtx = NULLHANDLE;2879 // HMTX hmtx = pFile->hmtx; 2880 // pFile->hmtx = NULLHANDLE; 2588 2881 2589 2882 // now that the file is locked, … … 2601 2894 } 2602 2895 2603 doshUnlockFile(pFile);2604 DosCloseMutexSem(pFile->hmtx);2896 // doshUnlockFile(pFile); 2897 // DosCloseMutexSem(pFile->hmtx); 2605 2898 } 2606 2899 … … 3961 4254 ULONG ul; 3962 4255 3963 printf(" type fs remot fixed parrm bootd media audio eas longn\n"); 4256 printf("Drive checker ("__DATE__")\n"); 4257 printf(" type fs remot fixed parrm bootd media audio eas longn\n"); 3964 4258 3965 4259 for (ul = 1; … … 3971 4265 0, // DRVFL_TOUCHFLOPPIES, 3972 4266 &xdi); 3973 PCSZ pcsz = "unknown";3974 4267 3975 4268 printf(" %c: ", xdi.cDriveLetter, ul); … … 3980 4273 { 3981 4274 if (arc) 3982 printf("error %4d\n", arc); 4275 printf("error %d (IsFixedDisk: %d, QueryDiskParams %d, QueryMedia %d)\n", 4276 arc, 4277 xdi.arcIsFixedDisk, 4278 xdi.arcQueryDiskParams, 4279 xdi.arcQueryMedia); 3983 4280 else 3984 4281 { … … 3997 4294 ULONG ul2; 3998 4295 4296 PCSZ pcsz = NULL; 4297 3999 4298 switch (xdi.bType) 4000 4299 { 4001 case DRVTYPE_HARDDISK: pcsz = "H ARDDISK"; break;4002 case DRVTYPE_FLOPPY: pcsz = "FLOPPY 4003 case DRVTYPE_TAPE: pcsz = "TAPE 4004 case DRVTYPE_VDISK: pcsz = "VDISK 4005 case DRVTYPE_CDROM: pcsz = "CDROM 4006 case DRVTYPE_LAN: pcsz = "LAN 4300 case DRVTYPE_HARDDISK: pcsz = "HDISK "; break; 4301 case DRVTYPE_FLOPPY: pcsz = "FLOPPY"; break; 4302 case DRVTYPE_TAPE: pcsz = "TAPE "; break; 4303 case DRVTYPE_VDISK: pcsz = "VDISK "; break; 4304 case DRVTYPE_CDROM: pcsz = "CDROM "; break; 4305 case DRVTYPE_LAN: pcsz = "LAN "; break; 4007 4306 case DRVTYPE_PARTITIONABLEREMOVEABLE: 4008 pcsz = "PARTREMV"; break; 4307 pcsz = "PRTREM"; break; 4308 default: 4309 printf("bType=%d, BPB.bDevType=%d", 4310 xdi.bType, 4311 xdi.bpb.bDeviceType); 4312 printf("\n "); 4009 4313 } 4010 4314 4011 printf("%s ", pcsz); 4012 4013 printf("%8s ", xdi.szFileSystem); // , xdi.bFileSystem); 4315 if (pcsz) 4316 printf("%s ", pcsz); 4317 4318 if (xdi.lFileSystem < 0) 4319 // negative means error 4320 printf("E%3d ", xdi.lFileSystem); // , xdi.bFileSystem); 4321 else 4322 printf("%7s ", xdi.szFileSystem); // , xdi.bFileSystem); 4014 4323 4015 4324 for (ul2 = 0; … … 4020 4329 printf(" X "); 4021 4330 else 4022 printf(" - "); 4331 if ( (xdi.arcOpenLongnames) 4332 && (aulFlags[ul2] == DFL_SUPPORTS_LONGNAMES) 4333 ) 4334 printf(" E%03d ", xdi.arcOpenLongnames); 4335 else 4336 printf(" - "); 4023 4337 } 4024 4338 printf("\n"); -
trunk/src/helpers/dosh2.c
r129 r135 2113 2113 * one will. 2114 2114 * 2115 * -- THIS COMPARES WITH RESPECT TO CASE. 2116 * 2115 2117 * This replaces strhMatchOS2 which has been removed with 2116 2118 * V0.9.16 and is a lot faster than the old code, which has … … 2120 2122 */ 2121 2123 2122 BOOL doshMatch (const char *pcszMask, // in: mask (e.g. "*.txt")2123 const char *pcszName) // in: string to check (e.g. "test.txt")2124 BOOL doshMatchCase(const char *pcszMask, // in: mask (e.g. "*.TXT") 2125 const char *pcszName) // in: string to check (e.g. "TEST.TXT") 2124 2126 { 2125 2127 BOOL brc = FALSE; … … 2128 2130 iNameDrive = -1; 2129 2131 2130 ULONG cbMask = strlen(pcszMask),2131 cbName = strlen(pcszName);2132 PSZ pszMask = (PSZ)_alloca(cbMask + 1),2133 pszName = (PSZ)_alloca(cbName + 1);2132 // ULONG cbMask = strlen(pcszMask), 2133 // cbName = strlen(pcszName); 2134 // PSZ pszMask = (PSZ)_alloca(cbMask + 1), 2135 // pszName = (PSZ)_alloca(cbName + 1); 2134 2136 2135 2137 PCSZ pLastMaskComponent, … … 2141 2143 CHAR c; 2142 2144 2143 memcpy(pszMask, pcszMask, cbMask + 1); 2144 nlsUpper(pszMask, cbMask); 2145 memcpy(pszName, pcszName, cbName + 1); 2146 nlsUpper(pszName, cbName); 2147 2148 if (pLastMaskComponent = strrchr(pszMask, '\\')) 2145 if (pLastMaskComponent = strrchr(pcszMask, '\\')) 2149 2146 { 2150 2147 // length of path component 2151 cbMaskPath = pLastMaskComponent - p szMask;2148 cbMaskPath = pLastMaskComponent - pcszMask; 2152 2149 pLastMaskComponent++; 2153 2150 } 2154 2151 else 2155 pLastMaskComponent = p szMask;2156 2157 if (pLastNameComponent = strrchr(p szName, '\\'))2152 pLastMaskComponent = pcszMask; 2153 2154 if (pLastNameComponent = strrchr(pcszName, '\\')) 2158 2155 { 2159 2156 // length of path component 2160 cbNamePath = pLastNameComponent - p szName;2157 cbNamePath = pLastNameComponent - pcszName; 2161 2158 pLastNameComponent++; 2162 2159 } 2163 2160 else 2164 pLastNameComponent = p szName;2161 pLastNameComponent = pcszName; 2165 2162 2166 2163 // compare paths; if the lengths are different … … 2168 2165 if ( (cbMaskPath == cbNamePath) // can both be null 2169 2166 && ( (cbMaskPath == 0) 2170 || (!memcmp(p szMask, pszName, cbMaskPath))2167 || (!memcmp(pcszMask, pcszName, cbMaskPath)) 2171 2168 ) 2172 2169 ) … … 2183 2180 } 2184 2181 2185 2182 /* 2183 *@@ doshMatch: 2184 * like doshMatchCase, but compares without respect 2185 * to case. 2186 * 2187 *@@added V0.9.16 (2002-01-26) [umoeller] 2188 */ 2189 2190 BOOL doshMatch(const char *pcszMask, // in: mask (e.g. "*.TXT") 2191 const char *pcszName) // in: string to check (e.g. "TEST.TXT") 2192 { 2193 ULONG cbMask = strlen(pcszMask), 2194 cbName = strlen(pcszName); 2195 PSZ pszMask = (PSZ)_alloca(cbMask + 1), 2196 pszName = (PSZ)_alloca(cbName + 1); 2197 2198 memcpy(pszMask, pcszMask, cbMask + 1); 2199 nlsUpper(pszMask, cbMask); 2200 memcpy(pszName, pcszName, cbName + 1); 2201 nlsUpper(pszName, cbName); 2202 2203 return (doshMatchCase(pszMask, 2204 pszName)); 2205 } -
trunk/src/helpers/gpih.c
r131 r135 55 55 #include "setup.h" // code generation and debugging options 56 56 57 #ifdef WINH_STANDARDWRAPPERS 58 #undef WINH_STANDARDWRAPPERS 59 #endif 57 60 #include "helpers\winh.h" 58 61 #include "helpers\gpih.h" -
trunk/src/helpers/winh.c
r132 r135 217 217 // put the call in brackets so the macro won't apply here 218 218 return (WinSetDlgItemText)(hwnd, id, (PSZ)pcsz); 219 } 220 221 /* 222 *@@ winhRequestMutexSem: 223 * 224 *@@added V0.9.16 (2002-01-26) [umoeller] 225 */ 226 227 APIRET winhRequestMutexSem(HMTX hmtx, ULONG ulTimeout) 228 { 229 // put the call in brackets so the macro won't apply here 230 return (WinRequestMutexSem)(hmtx, ulTimeout); 219 231 } 220 232
Note:
See TracChangeset
for help on using the changeset viewer.