天天看點

apr_file_seek 踩坑

定義:

apr_status_t apr_file_seek  ( apr_file_t *  thefile,
apr_seek_where_t  where,
apr_off_t *   offset 
)      

Move the read/write file offset to a specified byte within a file.

Parameters

thefile The file descriptor
where How to move the pointer, one of:
  • ​​APR_SET​​ – set the offset to offset
  • ​​APR_CUR​​ – add the offset to the current position
  • ​​APR_END​​ – add the offset to the current file size
offset The offset to move the pointer to.

Remarks

The third argument is modified to be the offset the pointer was actually moved to.

根據定義,  當設定為APR_END  時, 檔案指針指向檔案尾,

測試檔案内容為a.txt:TVVEVS1DTE9VRC1ITUFDLVN, 總共為24位

執行

apr_file_seek(file, APR_END, &offset)

日志列印為: