Changeset 21564 for trunk/src/kernel32/hmfile.cpp
- Timestamp:
- Jan 19, 2011, 10:56:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmfile.cpp
r21329 r21564 42 42 static void ParsePath(LPCSTR lpszFileName, LPSTR lpszParsedFileName, DWORD length); 43 43 44 45 class HMFileInfo 46 { 47 public: 48 HMFileInfo(HANDLE hFile, LPSTR lpszFileName, PVOID lpSecurityAttributes); 49 ~HMFileInfo(); 50 51 char *lpszFileName; 52 PVOID lpSecurityAttributes; 53 DWORD dwLXOffset; 54 }; 55 56 44 57 /***************************************************************************** 45 58 * Name : DWORD HMDeviceFileClass::CreateFile … … 52 65 * Variables : 53 66 * Result : 54 * Remark : 67 * Remark : 55 68 * Status : NO_ERROR - API succeeded 56 69 * other - what is to be set in SetLastError … … 74 87 lpSecurityAttributes, 75 88 pHMHandleDataTemplate)); 76 89 77 90 ParsePath(lpFileName, filepath, sizeof(filepath)); 78 91 … … 120 133 * Remark : TODO: Check if this implementation is complete and 100% correct 121 134 * UTC Time or Localtime ? 122 * GetFileTime is changed, Returns UTC-time yet !!!!! 135 * GetFileTime is changed, Returns UTC-time yet !!!!! 123 136 * Status : NO_ERROR - API succeeded 124 137 * other - what is to be set in SetLastError … … 187 200 #if 1 /* Canonicalize the path should be the right thing to do I think... */ 188 201 GetFullPathNameA(lpFileName, sizeof(filepath), filepath, NULL); 189 #else 202 #else 190 203 ParsePath(lpFileName, filepath, sizeof(filepath)); 191 204 #endif … … 201 214 strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME); 202 215 pOFStruct->szPathName[OFS_MAXPATHNAME-1] = 0; 203 204 205 /* 216 217 218 /* 206 219 * Do the parse stuff now and do a quick exit. 207 * Based on testcase (5) and MSDN: 220 * Based on testcase (5) and MSDN: 208 221 * "OF_PARSE Fills the OFSTRUCT structure but carries out no other action." 209 222 */ … … 217 230 return NO_ERROR; 218 231 } 219 232 220 233 221 234 hFile = OSLibDosOpenFile((LPSTR)lpFileName, fuMode); 222 235 223 236 if(hFile != INVALID_HANDLE_ERROR) 224 237 { … … 229 242 NULL, 230 243 &filetime ); 231 232 /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */ 244 245 /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */ 233 246 FileTimeToDosDateTime(&filetime, 234 247 &filedatetime[0], 235 248 &filedatetime[1] ); 236 249 memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved)); 237 250 238 251 if(fuMode & OF_DELETE) 239 252 { … … 247 260 hFile = HFILE_ERROR; 248 261 } 249 262 250 263 if((fuMode & OF_VERIFY)) 251 264 {//TODO: what's this?? we copy the time above... … … 257 270 hFile = HFILE_ERROR; 258 271 } 259 272 260 273 pOFStruct->nErrCode = GetLastError(); 261 274 pHMHandleData->hHMHandle = hFile; 262 275 263 276 if(hFile != HFILE_ERROR) { 264 277 pHMHandleData->dwUserData = (DWORD) new HMFileInfo(hFile, (LPSTR)lpFileName, NULL); … … 268 281 else { 269 282 DWORD rc = GetLastError(); 270 283 271 284 if(fuMode & OF_EXIST) 272 285 { … … 393 406 * Result : TRUE / FALSE 394 407 * Remark : 395 * Status : 408 * Status : 396 409 * 397 410 * Author : SvL … … 617 630 if((nNumberOfBytesToWrite+offset) & 0xfff) 618 631 nrpages++; 619 632 620 633 map->commitRange((ULONG)lpBuffer, offset & ~0xfff, FALSE, nrpages); 621 634 map->Release(); … … 697 710 lpHMDeviceName, pHMHandleData, pHFI)); 698 711 699 if(OSLibDosGetFileInformationByHandle(pHMHandleData->hHMHandle, 712 HMFileInfo *fileInfo = (HMFileInfo *)pHMHandleData->dwUserData; 713 if(OSLibDosGetFileInformationByHandle(fileInfo->lpszFileName, 714 pHMHandleData->hHMHandle, 700 715 pHFI)) 701 716 { … … 853 868 if(fileInfo && fileInfo->dwLXOffset) 854 869 { 855 switch(dwMoveMethod) 870 switch(dwMoveMethod) 856 871 { 857 872 case FILE_BEGIN: … … 1106 1121 * Variables : 1107 1122 * Result : BOOLEAN 1108 * Remark : 1123 * Remark : 1109 1124 * Status : 1110 1125 * … … 1130 1145 // 1131 1146 // When the application opens a file with CreateFile and 0 for desired access, 1132 // then we need to create a handle with limited access. 1147 // then we need to create a handle with limited access. 1133 1148 // 1134 1149 // MSDN: 1135 1150 // 1136 // If this parameter is zero, the application can query file and device attributes 1137 // without accessing the device. This is useful if an application wants to determine 1151 // If this parameter is zero, the application can query file and device attributes 1152 // without accessing the device. This is useful if an application wants to determine 1138 1153 // the size of a floppy disk drive and the formats it supports without requiring 1139 1154 // a floppy in the drive. It can also be used to test for the file's or directory's … … 1153 1168 * Variables : 1154 1169 * Result : 1155 * Remark : 1170 * Remark : 1156 1171 * Status : NO_ERROR - API succeeded 1157 1172 * other - what is to be set in SetLastError … … 1173 1188 lpSecurityAttributes, 1174 1189 pHMHandleDataTemplate)); 1175 1190 1176 1191 ParsePath(lpFileName, filepath, sizeof(filepath)); 1177 1192 … … 1242 1257 WIN32_FIND_DATAA finddata; 1243 1258 HANDLE hFind; 1244 1259 1245 1260 hFind = FindFirstFileA(fileInfo->lpszFileName, &finddata); 1246 1261 if(hFind == INVALID_HANDLE_VALUE) { … … 1290 1305 WIN32_FIND_DATAA finddata; 1291 1306 HANDLE hFind; 1292 1307 1293 1308 hFind = FindFirstFileA(fileInfo->lpszFileName, &finddata); 1294 1309 if(hFind == INVALID_HANDLE_VALUE) { … … 1300 1315 FindClose(hFind); 1301 1316 1302 if(fileInfo->dwLXOffset) 1317 if(fileInfo->dwLXOffset) 1303 1318 { 1304 1319 //subtract the LX header and magic qword from the file size … … 1314 1329 * Variables : 1315 1330 * Result : BOOLEAN 1316 * Remark : 1331 * Remark : 1317 1332 * Status : 1318 1333 * … … 1355 1370 HMFileInfo::HMFileInfo(HANDLE hFile, LPSTR lpszFileName, PVOID lpSecurityAttributes) 1356 1371 { 1372 // get the full path (this is necessary in particular for GetFileInformationByHandle) 1373 char fullPath[260]; 1374 if (!OSLibDosQueryPathInfo(lpszFileName, FIL_QUERYFULLNAME, fullPath, sizeof(fullPath))) { 1375 lpszFileName = fullPath; 1376 } 1377 1357 1378 this->lpszFileName = (LPSTR)malloc(strlen(lpszFileName)+1); 1358 1379 if(!this->lpszFileName) { … … 1366 1387 //an LX header. We need to skip that to present the original file to the 1367 1388 //caller 1368 if(hFile && !stricmp(lpszFileName + strlen(lpszFileName) - 4, ".EXE")) 1389 if(hFile && !stricmp(lpszFileName + strlen(lpszFileName) - 4, ".EXE")) 1369 1390 { 1370 1391 ULONG action, ulRead, signature, ulFileSize; … … 1385 1406 1386 1407 //Make sure it's an LX executable before continueing 1387 if(doshdr.e_magic != IMAGE_DOS_SIGNATURE || (WORD)signature != IMAGE_OS2_SIGNATURE_LX) 1408 if(doshdr.e_magic != IMAGE_DOS_SIGNATURE || (WORD)signature != IMAGE_OS2_SIGNATURE_LX) 1388 1409 { 1389 1410 goto failure;
Note:
See TracChangeset
for help on using the changeset viewer.