- Timestamp:
- Oct 22, 2013 3:34:41 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/winphone/pjlib/src/pj/file_access_win32.c
r4618 r4629 34 34 #endif 35 35 36 static pj_status_t get_file_size(HANDLE hFile, pj_off_t *size) 37 { 38 #ifdef PJ_WIN32_WINPHONE 39 FILE_STANDARD_INFO fileInfo; 40 41 if (GetFileInformationByHandleEx(hFile, FileStandardInfo, &fileInfo, 42 sizeof(FILE_STANDARD_INFO))) 43 { 44 *size = fileInfo.AllocationSize.QuadPart; 45 } else { 46 *size = -1; 47 return PJ_RETURN_OS_ERROR(GetLastError()); 48 } 49 #else 50 DWORD sizeLo, sizeHi; 51 52 sizeLo = GetFileSize(hFile, &sizeHi); 53 if (sizeLo == INVALID_FILE_SIZE) { 54 DWORD dwStatus = GetLastError(); 55 if (dwStatus != NO_ERROR) { 56 *size = -1; 57 return PJ_RETURN_OS_ERROR(dwStatus); 58 } 59 } 60 *size = sizeHi; 61 *size = ((*size) << 32) + sizeLo; 62 #endif 63 return PJ_SUCCESS; 64 } 65 36 66 static HANDLE WINAPI create_file(LPCTSTR filename, DWORD desired_access, 37 67 DWORD share_mode, … … 41 71 HANDLE template_file) 42 72 { 43 #ifdef PJ_WIN32_WINPHONE 73 #ifdef PJ_WIN32_WINPHONE 74 PJ_UNUSED_ARG(security_attributes); 75 PJ_UNUSED_ARG(flags_and_attributes); 76 PJ_UNUSED_ARG(template_file); 77 44 78 return CreateFile2(filename, desired_access, share_mode, 45 79 creation_disposition, NULL); … … 81 115 { 82 116 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 83 HANDLE hFile; 84 DWORD sizeLo, sizeHi; 117 HANDLE hFile; 85 118 pj_off_t size; 86 119 … … 95 128 return -1; 96 129 97 sizeLo = GetFileSize(hFile, &sizeHi); 98 if (sizeLo == INVALID_FILE_SIZE) { 99 DWORD dwStatus = GetLastError(); 100 if (dwStatus != NO_ERROR) { 101 CloseHandle(hFile); 102 return -1; 103 } 104 } 105 106 size = sizeHi; 107 size = (size << 32) + sizeLo; 130 get_file_size(hFile, &size); 108 131 109 132 CloseHandle(hFile); … … 158 181 pj_time_val *time_val) 159 182 { 160 FILETIME local_file_time;183 //FILETIME local_file_time; 161 184 SYSTEMTIME localTime; 162 185 pj_parsed_time pt; 163 186 164 if (!FileTimeToLocalFileTime(file_time, &local_file_time))165 return PJ_RETURN_OS_ERROR(GetLastError());187 //if (!FileTimeToLocalFileTime(file_time, &local_file_time)) 188 // return PJ_RETURN_OS_ERROR(GetLastError()); 166 189 167 190 if (!FileTimeToSystemTime(file_time, &localTime)) … … 192 215 PJ_DECL_UNICODE_TEMP_BUF(wfilename,256) 193 216 HANDLE hFile; 194 DWORD sizeLo, sizeHi;195 217 FILETIME creationTime, accessTime, writeTime; 218 #ifdef PJ_WIN32_WINPHONE 219 FILE_BASIC_INFO fileInfo; 220 #endif 196 221 197 222 PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL); … … 204 229 if (hFile == INVALID_HANDLE_VALUE) 205 230 return PJ_RETURN_OS_ERROR(GetLastError()); 206 207 sizeLo = GetFileSize(hFile, &sizeHi); 208 if (sizeLo == INVALID_FILE_SIZE) { 209 DWORD dwStatus = GetLastError(); 210 if (dwStatus != NO_ERROR) { 211 CloseHandle(hFile); 212 return PJ_RETURN_OS_ERROR(dwStatus); 213 } 214 } 215 216 stat->size = sizeHi; 217 stat->size = (stat->size << 32) + sizeLo; 218 231 232 if (get_file_size(hFile, &stat->size) != PJ_SUCCESS) { 233 CloseHandle(hFile); 234 return PJ_RETURN_OS_ERROR(GetLastError()); 235 } 236 #ifdef PJ_WIN32_WINPHONE 237 if (GetFileInformationByHandleEx(hFile, FileBasicInfo, &fileInfo, 238 sizeof(FILE_BASIC_INFO))) 239 { 240 creationTime.dwLowDateTime = fileInfo.CreationTime.LowPart; 241 creationTime.dwHighDateTime = fileInfo.CreationTime.HighPart; 242 accessTime.dwLowDateTime = fileInfo.LastAccessTime.LowPart; 243 accessTime.dwHighDateTime = fileInfo.LastAccessTime.HighPart; 244 writeTime.dwLowDateTime = fileInfo.LastWriteTime.LowPart; 245 writeTime.dwHighDateTime = fileInfo.LastWriteTime.HighPart; 246 } else { 247 CloseHandle(hFile); 248 return PJ_RETURN_OS_ERROR(GetLastError()); 249 } 250 #else 219 251 if (GetFileTime(hFile, &creationTime, &accessTime, &writeTime)==FALSE) { 220 252 DWORD dwStatus = GetLastError(); … … 222 254 return PJ_RETURN_OS_ERROR(dwStatus); 223 255 } 256 #endif 224 257 225 258 CloseHandle(hFile);
Note: See TracChangeset
for help on using the changeset viewer.