Changeset 5539 for pjproject/trunk/pjlib/src/pj/file_io_win32.c
- Timestamp:
- Jan 23, 2017 4:32:34 AM (8 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
- Property svn:mergeinfo changed
/pjproject/branches/projects/uwp (added) merged: 5208,5210-5211,5254,5256,5298,5439,5470,5497,5511-5515,5526,5528-5529,5532,5538 -
Property
svn:global-ignores
set to
bin
obj
lib
Bin
output
Debug
Generated[^A-Ba-b0-9]Files
Service[^A-Ba-b0-9]References
*.opendb
*.db
*.user
- Property svn:mergeinfo changed
-
pjproject/trunk/pjlib/src/pj/file_io_win32.c
r4537 r5539 22 22 #include <pj/errno.h> 23 23 #include <pj/assert.h> 24 #include <pj/string.h> 24 25 25 26 #include <windows.h> … … 28 29 # define INVALID_SET_FILE_POINTER ((DWORD)-1) 29 30 #endif 31 32 static pj_status_t set_file_pointer(pj_oshandle_t fd, 33 pj_off_t offset, 34 pj_off_t* newPos, 35 DWORD dwMoveMethod) 36 { 37 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 38 LARGE_INTEGER liDistance, liNewPos; 39 40 liDistance.QuadPart = offset; 41 if (!SetFilePointerEx(fd, liDistance, &liNewPos, dwMoveMethod)) { 42 return PJ_RETURN_OS_ERROR(GetLastError()); 43 } 44 *newPos = liNewPos.QuadPart; 45 #else 46 DWORD dwNewPos; 47 LONG hi32; 48 49 hi32 = (LONG)(offset >> 32); 50 51 dwNewPos = SetFilePointer(fd, (long)offset, &hi32, dwMoveMethod); 52 if (dwNewPos == (DWORD)INVALID_SET_FILE_POINTER) { 53 DWORD dwStatus = GetLastError(); 54 if (dwStatus != 0) 55 return PJ_RETURN_OS_ERROR(dwStatus); 56 /* dwNewPos actually is not an error. */ 57 } 58 *newPos = hi32; 59 *newPos = (*newPos << 32) + dwNewPos; 60 #endif 61 62 return PJ_SUCCESS; 63 } 30 64 31 65 /** … … 46 80 pj_oshandle_t *fd) 47 81 { 48 PJ_DECL_UNICODE_TEMP_BUF(wpathname, 256)82 PJ_DECL_UNICODE_TEMP_BUF(wpathname, 256) 49 83 HANDLE hFile; 50 84 DWORD dwDesiredAccess = 0; … … 87 121 88 122 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; 123 89 124 dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL; 90 125 91 hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 126 #if defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8 127 hFile = CreateFile2(PJ_STRING_TO_NATIVE(pathname, 128 wpathname, sizeof(wpathname)), 129 dwDesiredAccess, dwShareMode, dwCreationDisposition, 130 NULL); 131 #else 132 hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname, 133 wpathname, sizeof(wpathname)), 92 134 dwDesiredAccess, dwShareMode, NULL, 93 dwCreationDisposition, dwFlagsAndAttributes, NULL); 135 dwCreationDisposition, dwFlagsAndAttributes, NULL); 136 #endif 137 94 138 if (hFile == INVALID_HANDLE_VALUE) { 139 DWORD lastErr = GetLastError(); 95 140 *fd = 0; 96 return PJ_RETURN_OS_ERROR( GetLastError());141 return PJ_RETURN_OS_ERROR(lastErr); 97 142 } 98 143 … … 181 226 { 182 227 DWORD dwMoveMethod; 183 DWORD dwNewPos; 184 LONG hi32; 228 pj_off_t newPos; 185 229 186 230 if (whence == PJ_SEEK_SET) … … 195 239 } 196 240 197 hi32 = (LONG)(offset >> 32); 198 dwNewPos = SetFilePointer(fd, (long)offset, &hi32, dwMoveMethod); 199 if (dwNewPos == (DWORD)INVALID_SET_FILE_POINTER) { 200 DWORD dwStatus = GetLastError(); 201 if (dwStatus != 0) 202 return PJ_RETURN_OS_ERROR(dwStatus); 203 /* dwNewPos actually is not an error. */ 241 if (set_file_pointer(fd, offset, &newPos, dwMoveMethod) != PJ_SUCCESS) { 242 return PJ_RETURN_OS_ERROR(GetLastError()); 204 243 } 205 244 … … 210 249 pj_off_t *pos) 211 250 { 212 LONG hi32 = 0; 213 DWORD lo32; 214 215 lo32 = SetFilePointer(fd, 0, &hi32, FILE_CURRENT); 216 if (lo32 == (DWORD)INVALID_SET_FILE_POINTER) { 217 DWORD dwStatus = GetLastError(); 218 if (dwStatus != 0) 219 return PJ_RETURN_OS_ERROR(dwStatus); 220 } 221 222 *pos = hi32; 223 *pos = (*pos << 32) + lo32; 251 if (set_file_pointer(fd, 0, pos, FILE_CURRENT) != PJ_SUCCESS) { 252 return PJ_RETURN_OS_ERROR(GetLastError()); 253 } 254 224 255 return PJ_SUCCESS; 225 256 }
Note: See TracChangeset
for help on using the changeset viewer.