For large file files

zhaozj2021-02-16  121

Since the usual file displacement is expressed with 32-bit symbolic integers, the maximum limit of file displacement is 2G, which is required to be removed for large files.

Feasible approach:

Ants move, turn large displacement into continuous small displacement. This method can be kept to maximize compatibility. Disadvantages: Surface to the SEEK library function, such as under Windows, the implementation of the Seek is converted to an absolute displacement (seek_cur), which is invalid. Use 64-bit displacement. This method cannot be kept compatible. Disadvantages: This extension is provided not every Seek implementation.

Suggestions:

Under Windows: Use the CreateFile / SetFilePointer in the Win32 API to operate, avoid using Open / SEEK, which can not be compatible, but can solve large file issues well. Under Linux: It is recommended to use the following code: #ifndef __Use_largefile64

#define __Use_Largefile64

#ENDIF

#include

This allows 64-bit file operation API, but still suggests that the ant moves, doing a small displacement of the large bit to 2G, which is better to keep compatibility.

The last thing that needs to be explained, since the 0x80000000 == -0x80000000, the maximum value of the small displacement can be 0x7fffffff, which is actually considered alignment, using 0x7ffff0 relatively appropriate.

转载请注明原文地址:https://www.9cbs.com/read-8536.html

New Post(0)