Changeset 10071 for trunk/src/kernel32/hmfile.cpp
- Timestamp:
- May 6, 2003, 12:12:00 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmfile.cpp
r10064 r10071 1 /* $Id: hmfile.cpp,v 1.4 3 2003-05-05 10:51:05sandervl Exp $ */1 /* $Id: hmfile.cpp,v 1.44 2003-05-06 10:12:00 sandervl Exp $ */ 2 2 3 3 /* … … 164 164 LPSTR filenameinpath; 165 165 166 if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0 167 && !(fuMode & OF_CREATE) ) 166 if (SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0) 168 167 { 169 pOFStruct->nErrCode = ERROR_FILE_NOT_FOUND; 170 SetLastError(ERROR_FILE_NOT_FOUND); 171 return HFILE_ERROR; 168 if (!(fuMode & (OF_CREATE | OF_PARSE))) 169 { 170 pOFStruct->nErrCode = ERROR_FILE_NOT_FOUND; /* What about initializing the struct? */ 171 SetLastError(ERROR_FILE_NOT_FOUND); 172 return HFILE_ERROR; 173 } 174 175 /* 176 * OF_PARSE | OF_CREATE: 177 * Assume file in current directory. 178 */ 179 GetCurrentDirectoryA(sizeof(filepath), filepath); 180 strcat(strcat(filepath, "\\"), lpFileName); 181 GetLongPathNameA(filepath, filepath, sizeof(filepath)); 172 182 } 173 183 lpFileName = filepath; 174 184 } 175 185 else { 186 #if 1 /* Canonicalize the path should be the right thing to do I think... */ 187 GetFullPathNameA(lpFileName, sizeof(filepath), filepath, NULL); 188 #else 176 189 ParsePath(lpFileName, filepath, sizeof(filepath)); 190 #endif 177 191 178 192 //convert to long file name if in 8.3 hashed format 179 193 GetLongPathNameA(filepath, filepath, sizeof(filepath)); 180 181 194 lpFileName = filepath; 182 195 } … … 187 200 strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME); 188 201 pOFStruct->szPathName[OFS_MAXPATHNAME-1] = 0; 202 203 204 /* 205 * Do the parse stuff now and do a quick exit. 206 * Based on testcase (5) and MSDN: 207 * "OF_PARSE Fills the OFSTRUCT structure but carries out no other action." 208 */ 209 if (fuMode & OF_PARSE) 210 { 211 CHAR szDrive[4]; 212 *(PULONG)&szDrive[0] = *(PULONG)&pOFStruct->szPathName[0]; 213 szDrive[3] = '\0'; 214 pOFStruct->fFixedDisk = (GetDriveTypeA(szDrive) != DRIVE_REMOVABLE); 215 SetLastError(NO_ERROR); 216 return NO_ERROR; 217 } 218 189 219 190 220 hFile = OSLibDosOpenFile((LPSTR)lpFileName, fuMode); 191 221 192 222 if(hFile != INVALID_HANDLE_ERROR) 193 223 { … … 198 228 NULL, 199 229 &filetime ); 200 201 230 231 /* UTC Time or Localtime ? GetFileTime Returns UTC-time yet ? !!!!! */ 202 232 FileTimeToDosDateTime(&filetime, 203 233 &filedatetime[0], 204 234 &filedatetime[1] ); 205 235 memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved)); 206 236 207 237 if(fuMode & OF_DELETE) 208 238 { … … 216 246 hFile = HFILE_ERROR; 217 247 } 218 if(fuMode & OF_PARSE) 219 { 220 CHAR drive[4]; 221 222 drive[0] = pOFStruct->szPathName[0]; 223 drive[1] = pOFStruct->szPathName[1]; 224 drive[2] = pOFStruct->szPathName[2]; 225 drive[3] = 0; 226 227 pOFStruct->fFixedDisk = (GetDriveTypeA(drive) != DRIVE_REMOVABLE); 228 229 OSLibDosClose(hFile); 230 hFile = HFILE_ERROR; 231 } 232 248 233 249 if((fuMode & OF_VERIFY)) 234 { 250 {//TODO: what's this?? we copy the time above... 235 251 if(memcmp(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved))) 236 252 { … … 240 256 hFile = HFILE_ERROR; 241 257 } 242 258 243 259 pOFStruct->nErrCode = GetLastError(); 244 260 pHMHandleData->hHMHandle = hFile; 245 261 246 262 if(hFile != HFILE_ERROR) { 247 263 pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, NULL); … … 251 267 else { 252 268 DWORD rc = GetLastError(); 253 269 254 270 if(fuMode & OF_EXIST) 255 271 {
Note:
See TracChangeset
for help on using the changeset viewer.