Home > Back-end >  File truncation application scenario is what? Why we need to implement a truncated?
File truncation application scenario is what? Why we need to implement a truncated?

Time:11-25

I am learning embedded driver, feel a little idle, so I looked at some user space such as c + + programming method, less programming experience, see file truncation, a little confused the use scenarios, is to save space?

CodePudding user response:

I don't know you say what is truncated from interception want part of the file

CodePudding user response:

SetEndOfFile
The SetEndOfFile function moves The end - of - file (EOF) position for The specified file to The current position of The file pointer.

BOOL SetEndOfFile (
HANDLE the hFile//HANDLE of the file whose EOF is to be set
);

The Parameters
HFile
Handle to the file and its EOF position version. The file Handle must have had been created with GENERIC_WRITE access to the file.
The Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Few
This function can be 2 truncate or extend a file. If the file is extended, the contents of the file between the old EOF the position and the new position are not defined.

If you called CreateFileMapping to create a file - mapping object for hFile, you must first call UnmapViewOfFile to unmap all views and call the CloseHandle to close the file - mapping object before you can call SetEndOfFile.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: the Requires version 1.0 or later.
Header: Declared in winbase. H.
The Import Library: Use kernel32. Lib.

See Also
The File I/O the Overview, the File Functions provides, CloseHandle, CreateFile, CreateFileMapping, UnmapViewOfFile


CodePudding user response:

reference 1st floor paschen response:
I don't know you say what is truncated, from interception want part of the file

The appearance of a little different, as if she were deleting files during the second half of the, basically, I don't understand, just ask

CodePudding user response:

reference 1st floor paschen response:
I don't know you say what is truncated, from interception want part of the file

The appearance of a little different, as if she were deleting files during the second half of the, basically, I don't understand, just ask

CodePudding user response:

refer to the second floor zhao4zhong1 response:
SetEndOfFile
The SetEndOfFile function moves The end - of - file (EOF) position for The specified file to The current position of The file pointer.

BOOL SetEndOfFile (
HANDLE the hFile//HANDLE of the file whose EOF is to be set
);

The Parameters
HFile
Handle to the file and its EOF position version. The file Handle must have had been created with GENERIC_WRITE access to the file.
The Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Few
This function can be 2 truncate or extend a file. If the file is extended, the contents of the file between the old EOF the position and the new position are not defined.

If you called CreateFileMapping to create a file - mapping object for hFile, you must first call UnmapViewOfFile to unmap all views and call the CloseHandle to close the file - mapping object before you can call SetEndOfFile.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: the Requires version 1.0 or later.
Header: Declared in winbase. H.
The Import Library: Use kernel32. Lib.

See Also
The File I/O the Overview, the File Functions provides, CloseHandle, CreateFile, CreateFileMapping, UnmapViewOfFile


So EOF is a kind of truncation approach?

CodePudding user response:

https://www.baidu.com/s? Wd=SetEndOfFile

CodePudding user response:

The second half of the delete files, but have what use

CodePudding user response:

Don't content just to delete all located at the end of the file...

CodePudding user response:

A file consists of a number of records, for example, use the delete tags some unused records (not really delete), then the compressed file is too large to organize files, will take away my useful behind the record to the front of the empty position (position marked for deletion of records), finally, truncate the file,

CodePudding user response:

Truncate the file was deleted file some data, such as log file, growth every day, but when the data is too big and too long don't need the data would be truncated, used to reduce the file size
  • Related