Use Microsoft's FCI/FDI library for file compression

Source: Internet
Author: User
Tags bool prototype definition

Now do the project because the log content is too much, even to several G. Therefore, the user requires the program can automatically compress the resulting log to facilitate the save and send. This article briefly introduces Microsoft's FCI/FDI library, hoping to be helpful to everyone.

Brief introduction:

FCI (file Compression Interface) and FDI (file decompression Interface) are the development packages provided by Microsoft for compression and decompression. The biggest benefit is that the Winnt, Win2000, WinXP systems all provide the corresponding API interface. Therefore, our program does not require an additional compression library.

This article comes with routines just to show you some simpler usage, and you can tap into other, more powerful features based on the documentation that Microsoft provides.

API Introduction:

FCI/FDI API uses a large number of callback functions, the specific function of the prototype definition you can refer to the header file.

First, FCI

FCI includes 5 APIs.

Fcicreate Create FCI context

Fciaddfile Add files to cabinet

Fciflushcabinet ends the current cabinet

Fciflushfolder ends the current folder and creates a new folder

Fcidestroy destroys FCI context

HFCI Diamondapi Fcicreate (
PERF PERF,//For returning error type
pfnfcifileplaced pfnfiledest,//used when a file spans multiple cabinet
Pfnfcialloc Pfnalloc,//used to allocate and free memory.
Pfnfcifree Pfnfree,
Pfnfciopen Pfnopen,//6 Create, read and write files separately
Pfnfciread Pfnread,//close, positioning and deletion.
Pfnfciwrite Pfnwrite,
Pfnfciclose Pfnclose,
Pfnfciseek Pfnseek,
Pfnfcidelete Pfndelete,
Pfnfcigettempfile PFNFCIGTF,//for generating temporary file names
Pccab Pccab,//is a detailed description of the compressed file by a pointer to a CCAB structure
such as: size, name, path, and so on.
void FAR * PV//Return some context parameters.
);
BOOL Diamondapi Fciaddfile (
HFCI HFCI,//context created by fcicreate
Char *pszsourcefile,//compressed file
Char *pszfilename,//The name of this file in the compressed package
BOOL Fexecute,//uncompressed file execution
Pfnfcigetnextcabinet getnextcab,//is called when the next cabinet is created, ignored here
Pfnfcistatus pfnprogress,//periodic callback function to show the progress of compression.
Pfnfcigetopeninfo pfnopeninfo,//Open file return file handle and attributes
Type of Tcomp typecompress//compression
)
BOOL Diamondapi Fciflushcabinet (
HFCI HFCI,//context created by fcicreate
BOOL Fgetnextcab,//Decide whether Getnextcab is invoked
Pfnfcigetnextcabinet getnextcab,//call when cabinet full
Pfnfcistatus pfnprogress//Fciaddfile
)
BOOL Diamondapi Fciflushfolder (
HFCI HFCI,//Parameter ditto
Pfnfcigetnextcabinet Getnextcab,
Pfnfcistatus pfnprogress
)

BOOL Diamondapi Fcidestroy (
HFCI HFCI
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.