Ticket #277: 277.2.diff
File 277.2.diff, 4.3 KB (added by , 11 years ago) |
---|
-
src/corelib/global/qglobal.cpp
1271 1271 \value OV_ECS_1_1 eComStation 1.1 1272 1272 \value OV_ECS_1_2 eComStation 1.2 1273 1273 \value OV_ECS_2_0 eComStation 2.0 (either any of RCs or GA) 1274 \value OV_ECS_2_1 eComStation 2.1 (either any of RCs or GA) 1275 \value OV_ECS_2_2 eComStation 2.2 (either any of RCs or GA) 1274 1276 1275 1277 The following masks can be used for detecting properties common to a group 1276 1278 of versions: … … 1971 1973 // Returns a version number of the component taken directly from its SYSLEVEL 1972 1974 // file (see http://www.edm2.com/index.php/Using_SYSLEVEL_Files_in_Your_Applications 1973 1975 // for more information about SYSLEVEL file internals) 1974 static bool getSyslevelVersion(const QByteArray &fileName, char (*version)[2]) 1976 // beginning from ecs 2.1 they changed the detection scheme once more 1977 // the information is now in the ecs_inst.flg file as plain text 1978 // the below function deals with both 1979 enum fileType { 1980 SysLevel, 1981 eCSFlg }; 1982 1983 static bool getSyslevelVersion(const QByteArray &fileName, char *version, fileType ft) 1975 1984 { 1976 1985 bool success = false; 1986 int offSet; 1987 size_t bytesToR; 1988 1989 if (ft == SysLevel) 1990 { 1991 offSet = 0x28; 1992 bytesToR = 2; 1993 } else { 1994 offSet = 0x0C; 1995 bytesToR = 3; 1996 } 1997 1977 1998 FILE *f = fopen(fileName, "rb"); 1978 1999 if (!f) 1979 2000 return success; 1980 // go to the char d_version[2] field of the SYSLEVELdata structure1981 if ((success = fseek(f, 0x28, SEEK_SET) == 0)) {2001 // go to the offset of the data structure 2002 if ((success = fseek(f, offSet, SEEK_SET) == 0)) { 1982 2003 // read in two bytes 1983 success = fread( *version, 1, 2, f) == 2;2004 success = fread(version, 1, bytesToR, f) == bytesToR; 1984 2005 } 1985 2006 fclose(f); 1986 2007 return success; … … 2025 2046 QByteArray fn = QByteArray("A:\\OS2\\INSTALL\\SYSLEVEL.OS2"); 2026 2047 fn.data()[0] += buf[0] - 1; 2027 2048 char sys_os2_ver[2]; 2028 if (!getSyslevelVersion(fn, &sys_os2_ver))2049 if (!getSyslevelVersion(fn, sys_os2_ver, SysLevel)) 2029 2050 return os2ver; 2030 2051 2031 2052 // read SYSLEVEL.ECS 2032 2053 fn = QByteArray("A:\\OS2\\INSTALL\\SYSLEVEL.ECS"); 2033 2054 fn.data()[0] += buf[0] - 1; 2034 2055 char sys_ecs_ver[2]; 2035 if (!getSyslevelVersion(fn, &sys_ecs_ver)) {2056 if (!getSyslevelVersion(fn, sys_ecs_ver, SysLevel)) { 2036 2057 // no or broken SYSLEVEL.ECS, it's either eCS 1.1 or below or non-eCS 2037 2058 bool have_ecsreg = false; 2038 2059 bool have_ecsreg11 = false; … … 2049 2070 if (have_ecsreg) 2050 2071 return os2ver = OV_ECS_1_0; 2051 2072 // detect WSeB (4.52) 2052 if (sys_os2_ver[0] == 0x45 && sys_os2_ver[1] == 0x02)2073 if (sys_os2_ver[0] == 0x45 && sys_os2_ver[1] == 0x02) 2053 2074 return os2ver = OV_4_52; 2054 2075 // fallback to Aurora (QSV_VERSION_MINOR is 45 here) 2055 2076 return os2ver = OV_4_5; … … 2058 2079 // detect eCS >= 1.2 2059 2080 if (sys_ecs_ver[0] == 0x12 && sys_ecs_ver[1] == 0x00) 2060 2081 return os2ver = OV_ECS_1_2; 2061 if (sys_ecs_ver[0] == 0x20 && sys_ecs_ver[1] == 0x00) 2062 return os2ver = OV_ECS_2_0; 2082 if (sys_ecs_ver[0] >= 0x20 && sys_ecs_ver[1] == 0x00) 2083 { 2084 os2ver = OV_ECS_2_0; 2085 // read ecs_inst.flg 2086 char flg_ecs_ver[3]; 2087 fn = QByteArray("A:\\ECS\\ECS_INST.FLG"); 2088 fn.data()[0] += buf[0] - 1; 2089 if (getSyslevelVersion(fn, flg_ecs_ver, eCSFlg)) { 2090 if (flg_ecs_ver[0] == '2' && flg_ecs_ver[2] == '1') 2091 os2ver = OV_ECS_2_1; 2092 if (flg_ecs_ver[0] == '2' && flg_ecs_ver[2] == '2') 2093 os2ver = OV_ECS_2_2; 2094 } 2095 return os2ver; 2096 } 2063 2097 2064 2098 return os2ver = OV_ECS_Unknown; 2065 2099 } -
src/corelib/global/qglobal.h
1566 1566 OV_ECS_1_1 = 0x06010100, 1567 1567 OV_ECS_1_2 = 0x06010200, 1568 1568 OV_ECS_2_0 = 0x06020000, 1569 OV_ECS_2_1 = 0x06020100, 1570 OV_ECS_2_2 = 0x06020200, 1569 1571 1570 1572 /* version masks */ 1571 1573 OV_WARP3 = 0x01000000,