Ignore:
Timestamp:
Oct 22, 2013 3:34:41 AM (11 years ago)
Author:
riza
Message:

Re #1704: fixed some build warnings and errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/winphone/pjlib/src/pj/file_io_win32.c

    r4618 r4629  
    185185*/ 
    186186 
     187static pj_status_t set_file_pointer(pj_oshandle_t fd, 
     188                                    pj_off_t offset, 
     189                                    pj_off_t* newPos, 
     190                                    DWORD dwMoveMethod) 
     191{ 
     192#ifdef PJ_WIN32_WINPHONE 
     193    LARGE_INTEGER liDistance, liNewPos;     
     194 
     195    liDistance.QuadPart = offset; 
     196    if (!SetFilePointerEx(fd, liDistance, &liNewPos, dwMoveMethod)) { 
     197        return PJ_RETURN_OS_ERROR(GetLastError()); 
     198    } 
     199    *newPos = liNewPos.QuadPart; 
     200#else 
     201    DWORD dwNewPos; 
     202    LONG  hi32; 
     203 
     204    hi32 = (LONG)(offset >> 32); 
     205 
     206    dwNewPos = SetFilePointer(fd, (long)offset, &hi32, dwMoveMethod); 
     207    if (dwNewPos == (DWORD)INVALID_SET_FILE_POINTER) { 
     208        DWORD dwStatus = GetLastError(); 
     209        if (dwStatus != 0) 
     210            return PJ_RETURN_OS_ERROR(dwStatus); 
     211        /* dwNewPos actually is not an error. */ 
     212    } 
     213    *newPos = hi32; 
     214    *newPos = (*newPos << 32) + dwNewPos; 
     215#endif 
     216 
     217    return PJ_SUCCESS; 
     218} 
     219 
    187220PJ_DEF(pj_status_t) pj_file_setpos( pj_oshandle_t fd, 
    188221                                    pj_off_t offset, 
     
    190223{ 
    191224    DWORD dwMoveMethod; 
    192     DWORD dwNewPos; 
    193     LONG  hi32; 
     225    pj_off_t newPos; 
    194226 
    195227    if (whence == PJ_SEEK_SET) 
     
    202234        pj_assert(!"Invalid whence in file_setpos"); 
    203235        return PJ_EINVAL; 
    204     } 
    205  
    206     hi32 = (LONG)(offset >> 32); 
    207     dwNewPos = SetFilePointer(fd, (long)offset, &hi32, dwMoveMethod); 
    208     if (dwNewPos == (DWORD)INVALID_SET_FILE_POINTER) { 
    209         DWORD dwStatus = GetLastError(); 
    210         if (dwStatus != 0) 
    211             return PJ_RETURN_OS_ERROR(dwStatus); 
    212         /* dwNewPos actually is not an error. */ 
     236    }     
     237     
     238    if (set_file_pointer(fd, offset, &newPos, dwMoveMethod) != PJ_SUCCESS) { 
     239        return PJ_RETURN_OS_ERROR(GetLastError()); 
    213240    } 
    214241 
     
    219246                                    pj_off_t *pos) 
    220247{ 
    221     LONG hi32 = 0; 
    222     DWORD lo32; 
    223  
    224     lo32 = SetFilePointer(fd, 0, &hi32, FILE_CURRENT); 
    225     if (lo32 == (DWORD)INVALID_SET_FILE_POINTER) { 
    226         DWORD dwStatus = GetLastError(); 
    227         if (dwStatus != 0) 
    228             return PJ_RETURN_OS_ERROR(dwStatus); 
    229     } 
    230  
    231     *pos = hi32; 
    232     *pos = (*pos << 32) + lo32; 
     248    if (set_file_pointer(fd, 0, pos, FILE_CURRENT) != PJ_SUCCESS) { 
     249        return PJ_RETURN_OS_ERROR(GetLastError()); 
     250    } 
     251 
    233252    return PJ_SUCCESS; 
    234253} 
Note: See TracChangeset for help on using the changeset viewer.