C/C ++ file input/output operations-file *, fstream, and windowsapi (full)

Source: Internet
Author: User
Tags rewind

C-based file operations
In ansi c, file operations are divided into two methods: stream file operations and I/O file operations, which are described below.

I. Stream File Operations
This method has an important structure for file operations.FileFile is defined in the header file stdio. h as follows:

Typedef struct {
Int level;/* fill/empty level of buffer */
Unsigned flags;/* file Status flags */
Char FD;/* file descriptor */
Unsigned char hold;/* ungetc char if no buffer */
Int bsize;/* buffer size */
Unsigned char _ far * buffer;/* Data Transfer Buffer */
Unsigned char _ far * CURP;/* current active pointer */
Unsigned istemp;/* temporary file indicator */
Short token;/* used for validity checking */
} File;/* This is the file object */

The file structure contains the basic attributes of file operations. All file operations must be performed through the pointer of this structure. For common functions of such file operations, see the following table functions.
Fopen () Open stream
Fclose () Close the stream
Fputc () writes a character to the stream
Fgetc () reads a character from the stream
Fseek () locates the specified character in the stream
Fputs () writes a string to a stream
Fgets () reads a row or a specified character from the stream.
Fprintf () Outputs Data to the stream in the format
Fscanf () reads data from the stream in the format
Returns the true value when feof () reaches the end of a file.
Returns the value of ferror () When an error occurs.
Rewind () resets the file locator to the beginning of the file
Remove () delete an object
Fread () reads a specified number of characters from a stream
Fwrite () writes a specified number of characters to the stream.
Tmpfile () generates a temporary file stream
Tmpnam () generates a unique file name

The following describes these functions.

1. fopen ()
The fopen prototype is file * fopen (const char * filename, const char * mode). fopen implements three functions.

Open a stream for use
Connect a file to this stream
Returns a filr pointer to the stream.
The filename parameter points to the name of the file to be opened. mode indicates the string in the open state. The values are as follows:

String meaning
R: open a read-only file, which must exist.
R + open a readable file, which must exist.
RB + read/write open a binary file and only allow read/write data.
RT + read/write: open a text file and allow reading and writing.
W. Open and write only the file. If the file exists, the file length is 0, indicating that the file content will disappear. If the file does not exist, the file is created.
W + open the readable and writable file. If the file exists, the file length is cleared to zero, that is, the file content disappears. If the file does not exist, the file is created.
A. Open and write-only files as an attachment. If the file does not exist, the file will be created. If the file exists, the written data will be added to the end of the file, that is, the original content of the file will be retained. (EOF reserved)
A + opens readable and writable files by appending them. If the file does not exist, the file will be created. If the file exists, the written data will be added to the end of the file, that is, the original content of the file will be retained. (The original EOF is not retained)
WB only opens or creates a new binary file; only data can be written.
WB + enables read/write operations or creates a binary file, allowing read and write operations.
Wt + read/write opens or creates a text file; read/write is allowed.
At + read/write opens a text file, allowing you to read or append data at the end of the text.
Open a binary file through AB + read/write, and allow you to read or append data to the end of the file.

A file can be opened in text or binary mode. The difference between the two is that in text mode, carriage return is treated as a character '\ n ', the binary mode considers it to be two characters: 0x0d and 0x0a. If you read 0x1b in the file, the text mode considers it to be the file Terminator, that is, the binary model does not process the file, the text mode will convert the data in a certain way.

By default, the system is enabled in text mode. You can modify the value of all variables _ fmode to modify this setting. For example, _ fmode = o_text; then, the default mode is set to text mode; _ fmode = o_binary; the default enable mode is binary.

This function returns a file pointer, so it does not need to be initialized after declaring a file pointer. Instead, it uses fopen () to return a pointer and connect it to a specific file. If it succeeds or fails, null is returned.

Example:

File * FP;
If (FP = fopen ("123.456", "WB "))
Puts ("file opened successfully ");
Else
Puts ("file opening success or failure ");

2. fclose ()
Fclose () is used to close files opened with fopen (). Its prototype is int fclose (File * FP). If the file is successful, 0 is returned. If the file is failed, EOF is returned.

When the program ends, remember to close the opened file. Otherwise, it may cause data loss. I used to make such a mistake.

Example: fclose (FP );

3. fputc ()
Write a character to the stream. The prototype is int fputc (int c, file * stream). If this character is returned successfully, EOF is returned for failure.

Example: fputc ('x', FP );

4. fgetc ()
Read a character from the stream. The prototype is int fputc (File * stream). If this character is returned successfully, EOF is returned if it fails.

Example: Char struct = fgetc (FP );

5. fseek ()
This function is generally used in files opened in binary mode. It is used to locate the specified position in the stream. The prototype is int fseek (File * stream, long offset, int whence ); if 0 is returned successfully, the offset parameter indicates the number of characters to be moved, and the whence parameter indicates the moving benchmark. The value is

Symbol constant value reference position
Start with seek_set 0
Seek_cur 1 Current read/write location
Seek_end 2 file tail

Example: fseek (FP, 1234l, seek_cur); // move the read/write position 1234 bytes backward from the current position (L suffix indicates a long integer)

Fseek (FP, 0l, 2); // move the read/write location to the end of the file

6. fputs ()
Write a string to the stream. The prototype is int fputs (const char * s, file * stream );

Example: fputs ("I love you", FP );

7. fgets ()
Read a row or a specified character from the stream. The prototype is char * fgets (char * s, int N, file * stream). Read n-1 characters from the stream, unless one line is read, the parameter S is used to receive strings. If the string is successful, the pointer of S is returned. Otherwise, null is returned.

For example, if the text at the current position of a file is as follows:

Love, I have

But ........

If you use

Fgets (str1, 4, file1 );

After execution, str1 = "lov" reads 4-1 = 3 characters.

Fgets (str1, 23, file1 );

Run STR = "love, I have" to read a row (excluding '\ n' at the end of the row ').

8. fprintf ()
Input to the stream in the format. Its prototype is int fprintf (File * stream, const char * Format [, argument,...]); the method is the same as printf (), but it is not written to the console, but to the stream.

Example: fprintf (FP, "% 2D % s", 4, "HAHAHA ");

9. fscanf ()
Read from the stream in the format. Its prototype is int fscanf (File * stream, const char * Format [, address,...]); the method is the same as scanf (), but it is not read from the console, but from the stream.

Example: fscanf (FP, "% d", & X, & Y );

10. feof ()
Check whether the end of the file is reached. If it is true, 0 is returned. The prototype is int feof (File * stream );

Example: If (feof (FP) printf ("ended at the end of the file ");

11. ferror ()
The prototype is int ferror (File * stream). The latest error code of the returned stream can be cleared by clearerr (). The prototype of clearerr () is void clearerr (File * stream );

Example: printf ("% d", ferror (FP ));

12. Rewind ()
Return the current read/write location to the start of the file. The prototype is void rewind (File * stream). In fact, this function is equivalent to fseek (FP, 0l, seek_set );

Example: rewind (FP );

13. Remove ()
Delete the file. The prototype is int remove (const char * filename). The parameter is the name of the file to be deleted. 0 is returned if the file is successfully deleted.

Example: Remove ("C: \ Io. sys ");

14. fread ()
Read a specified number of characters from the stream. The prototype is size_t fread (void * PTR, size_t size, size_t N, file * stream). The PTR parameter stores the read data, void * pointers can be replaced by pointers of any type, such as char * and int *. Size indicates the number of bytes in each block. N indicates the number of read blocks. If yes, returns the number of actually read parts (not the number of bytes). This function is generally used in files opened in binary mode.

Example:

Char X [4230];
File * file1 = fopen ("C: \ msdos. sys", "R ");

Fread (x, 200, 12, file1); // read 2400*12 = bytes in total

15. fwrite ()
Corresponds to fread and writes the specified data to the stream. The prototype is size_t fwrite (const void * PTR, size_t size, size_t N, file * stream ); the PTR parameter is the data pointer to be written. The Void * pointer can be replaced by any type of pointer, such as char * and int *. The size is the number of bytes per block; n is the number of blocks to be written. If the number of actually written blocks is returned (not the number of bytes), this function is generally used in files opened in binary mode.

Example:

Char X [] = "I Love You ";
Fwire (x, 6, 12, FP); // write 6*12 = 72 bytes

Write "I love" to the stream FP 12 times, a total of 72 bytes

16. tmpfile ()
The prototype is file * tmpfile (void). A temporary file is generated, opened in "W + B" mode, and a pointer to the temporary stream is returned. If the stream fails, null is returned. At the end of the program, the file will be automatically deleted.

Example: file * fp = tmpfile ();

17. tmpnam ();
Its prototype is char * tmpnam (char * s). A unique file name is generated. In fact, tmpfile () calls this function. The parameter S is used to save the obtained file name, returns the pointer. If the pointer fails, null is returned.

For example, tmpnam (str1 );

2. Direct I/O File Operations
This is another file operation provided by C. It processes the file by directly saving/retrieving the file, and the streaming file operation is carried out through the buffer; streaming file operations are performed around a file pointer, and such file operations are performed around a file's "handle". What is a handle? It is an integer that uniquely identifies a file (in windows, the handle concept is extended to the identifier of all device resources. Common functions for such file operations are listed in the following table. These functions and their symbols are defined in Io. h and fcntl. H, and corresponding header files must be added for use.

Function Description
Open () open a file and return its handle
Close () close a handle
Lseek () locates at the specified position of the file
Read () block Read File
Write () block Write File
Whether the EOF () test file is complete
Filelength () gets the file length
Rename () rename a file
Chsize () changes the file length

The following describes these functions:

1. open ()
Open a file and return its handle. If it fails, a value smaller than 0 will be returned. The prototype is int open (const char * path, int access [, unsigned mode]); the path parameter is the name of the file to be opened, the access mode is open, and the mode is optional. This parameter indicates the properties of a file. It is mainly used in UNIX systems and has no significance in DOS/windows. The file opening mode is shown in the following table.

Symbol Meaning symbol meaning
O_rdonly read-only mode o_wronly write-only mode o_rdwr read/write mode
O_ndelay is used to append o_creat to o_creat in the Unix system. If the file does not exist, it is created.
O_trunc cut the file length to 0 o_excl and o_creat. If the file has an error, the o_binary binary method is returned.
O_text text

You can use the "|" operator to connect to multiple requirements. For example, o_append | o_text indicates opening a file in text mode and append mode.

Example: int handle = open ("C: \ msdos. sys", o_binary | o_creat | o_write)

2. Close ()
Closes a handle. The prototype is int close (INT handle). If the handle is successful, 0 is returned.

Example: Close (handle)

3. lseek ()
Locate to the specified position. The prototype is long lseek (INT handle, long offset, int fromwhere). The offset parameter is the moving amount, and fromwhere is the moving reference position, the value is the same as fseek (). seek_set: First part of the file; seek_cur: Current Position of the file; seek_end: End of the file. This function returns the new file access location after execution.

Example:

Lseek (handle,-1234l, seek_cur); // moves the access location 1234 bytes forward from the current location.
X = lseek (hnd1, 0l, seek_end); // move the access location to the end of the file. x = The End of the file, that is, the length of the file.

4. Read ()
Read a block from the file. The prototype is int read (INT handle, void * Buf, unsigned Len). The parameter Buf stores the read data, and Len is the read byte. The function returns the bytes actually read.

Example: Char X [200]; read (hnd1, X, 200 );

5. Write ()
Write a piece of data to the file. The prototype is int write (INT handle, void * Buf, unsigned Len). The parameter meaning is the same as read (), and the actual written bytes are returned.

Example: Char X [] = "I Love You"; write (handle, X, strlen (x ));

7. EOF ()
Similar to feof (), if the test file ends, 1 is returned; otherwise, 0 is returned; prototype: int EOF (INT handle );

Example: While (! EOF (handle1 )){......};

8. filelength ()
The length of the returned file. The prototype is long filelength (INT handle). It is equivalent to lseek (handle, 0l, seek_end)

Example: long x = filelength (handle );

9. Rename ()
Rename the file. The prototype is int Rename (const char * oldname, const char * newname). The parameter oldname is the old file name and newname is the new file name. 0 is returned successfully.

For example, rename ("C: \ config. sys", "C: \ config. w40 ");

10. chsize ();
Change the file length. The prototype is int chsize (INT handle, Long SIZE). The parameter size indicates the new length of the file. 0 is returned for success; otherwise,-1 is returned, if the specified length is smaller than the file length, the file is truncated. If the specified length is greater than the file length, add '\ 0' after the file '.

Example: chsize (handle, 0x12345 );

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------

Same as streaming file operations, this also provides Unicode Character operation functions, such as _ wopen (), for wide character programming in 9x/NT, if you are interested, you can query the help of BCB.

In addition, this operation also includes functions such as lock (), unlock (), and locking () for multi-user operations, but it is not used much in BCB, so I will not introduce it, however, if you want to use C to write CGI, this is the common sense. If you have such requirements, you have to look at your own help.
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------

C ++-based file operations

In C ++, there isStreamThis class, all I/O are based on this "stream" class, including the file I/O we want to know. The stream class has two important operators:

1. Plug-in (<)
Output data to the stream. For example, the system has a default standard output stream (cout), which generally refers to the display, so cout <"Write stdout" <'\ n '; output the string "Write stdout" and line feed character ('\ n') to the standard output stream.

2. Analyze (>)
Input data from the stream. For example, the system has a default standard input stream (CIN), which generally refers to the keyboard. Therefore, CIN> X; read data of a specified type (that is, the type of variable X) from the standard input stream.

In C ++, operations on files are performed through the subclass of stream.Fstream(File stream). Therefore, to operate files in this way, you must add the header file fstream. h. The following describes how to operate such files.

1. Open a file
In the fstream class, a member function open () is used to open a file. Its prototype is:

Void open (const char * filename, int openmode, int access );

Parameters:

Filename: name of the file to be opened
Mode: how to open the file
Access: Open File Attributes
The file opening method is defined in class IOs (which is the base class of all stream I/O classes). The common values are as follows:

IOS: APP: open a file in append Mode
IOS: ate: After the file is opened, it is located at the end of the file. IOS: app contains this attribute.
IOS: Binary: open a file in binary mode. The default mode is text. For the differences between the two methods, see the previous article.
IOS: In: open the file as input (file => Program)
IOS: Out: open an output file (program => file)
IOS: nocreate: The file is not created, so opening fails if the file does not exist.
IOS: noreplace: Does not overwrite the file. Therefore, if the file fails to be opened
IOS: trunc: if the file exists, set the file length to 0.
You can use "or" to connect the preceding attributes, for example, IOS: Out | IOs: binary.

The attribute value for opening a file is:

0: normal file, open access
1: Read-Only files
2: Implicit File
4: system files
You can use "or" or "+" to connect the above attributes. For example, 3 or 1 | 2 means opening the file with read-only and implicit attributes.

For example, open the file c: \ config. sys in binary input mode.

Fstream file1;
File1.open ("C: \ config. sys", IOS: Binary | IOs: In, 0 );

If the OPEN function only has one parameter for the file name, it is opened by reading/writing a common file, that is:

File1.open ("C: \ config. sys "); <=> file1.open (" C: \ config. sys ", IOS: In | IOs: Out, 0 );

In addition, fstream has the same constructor as open (). For the above example, you can open the file at the time of definition:

Fstream file1 ("C: \ config. sys ");

In particular, fstream has two sub-classes: ifstream (input file stream) and ofstream (outpu file stream). ifstream opens a file (file => program) as input by default ), ofstream opens the file in output mode by default.

Ifstream file2 ("C: \ PDOS. Def"); // open the file as input
Ofstream file3 ("C: \ x.123"); // open the file in output mode

Therefore, in actual applications, select different classes as needed: If you want to open them as input, use ifstream to define them; if you want to open them as output, define it with ofstream. If you want to open it in input/output mode, define it with fstream.

Ii. Close files
You must close the opened file after it is used. fstream provides the member function close () to complete this operation, for example, file1.close (); to close the file connected to file1.

3. Read and Write files
Reading and writing a file can be divided into reading a text file and a binary file. reading a text file is relatively simple, and it can be done with an insertor or an analyzer. Binary reading is more complex, the two methods are described in detail below.

1. Read and Write text files
The reading and writing of text files is very simple: Use the plug-in (<) to output data to the file; Use the extract (>) to input data from the file. Suppose file1 is opened as input, and file2 is opened as output. Example:

File2 <"I Love You"; // write the string "I love you" to the file"
Int I;
File1> I; // enter an integer from the file.

This method also provides a simple formatting capability, such as specifying the output as hexadecimal. The specific formats include:

Operator Input/Output
Format dec as a decimal Value Data Input and Output
Endl outputs a line break and refresh the output.
Ends outputs an empty character output
Hex format to hexadecimal value data input and output
Oct format to octal numeric data input and output
Setpxecision (int p) is used to set the number of precise digits of a floating point.

For example, to output 123 as a hexadecimal value: file1 <123; to output 3.1415926 with a 5-bit precision: file1 <3.1415926.

2. Binary file read/write
① Put ()
The put () function writes a character to the stream. Its prototype is ofstream & put (char ch), which is also relatively simple to use, such as file1.put ('C '); it is to write a character 'C' to the stream '.

② Get ()
The get () function is flexible and has three common overload methods:

One is the form corresponding to put (): ifstream & get (char & Ch); the function is to read a character from the stream and save the result in the reference ch, if it is at the end of the file, null characters are returned. For example, file2.get (x); indicates reading a character from the file and saving the read character in X.

The prototype of another form of overload is: int get (); this form returns a character from the stream. If it reaches the end of the file, it returns EOF, for example, x = file2.get (); the function is the same as that of the previous example.

Another form of prototype is: ifstream & get (char * Buf, int num, char delim = '\ n'); this form reads characters into the array pointed by the Buf, the default linefeed '\ n' is used if the num character is read or the character specified by delim is encountered '. For example:

File2.get (str1, 127, 'A'); // read the character from the file to str1. It is terminated when 'A' or 127 characters are read.

③ Read/write data blocks
To read and write binary data blocks, use the member functions read () and write (). Their prototype is as follows:

Read (unsigned char * Buf, int num );
Write (const unsigned char * Buf, int num );

Read () reads num characters from the file to the cache pointed to by the Buf. If the number of num characters has not been read at the end of the file, you can use the member function int gcount (); and write () writes num characters from the cache directed to the Buf to the file. It is worth noting that the cache type is unsigned char *, sometimes type conversion is required.

Example:

Unsigned char str1 [] = "I Love You ";
Int N [5];
Ifstream in ("XXX. XXX ");
Ofstream out ("yyy. yyy ");
Out. Write (str1, strlen (str1); // write all str1 strings to yyy. yyy.
In. Read (unsigned char *) n, sizeof (n); // read the specified integer from XXX. XXX. Pay attention to type conversion.
In. Close (); Out. Close ();

Iv. EOF Detection
The member function EOF () is used to check whether it has reached the end of the file. If it has reached the end of the file, a non-0 value is returned; otherwise, 0 is returned. The prototype is int EOF ();

For example, if (in. EOF () showmessage ("has reached the end of the file! ");

V. File locating
Unlike C's file operations, the C ++ I/O system manages two pointers associated with a file. One is the read pointer, which indicates the position of the input operation in the file; the other is the write pointer, which is the position of the next write operation. The corresponding pointer automatically changes each time the input or output is executed. Therefore, file location in C ++ can be divided into read location and write location. The corresponding member functions are seekg () and seekp (). seekg () is used to set the read location, seekp is used to set the write position. Their most common forms are as follows:

Istream & seekg (streamoff offset, seek_dir origin );
Ostream & seekp (streamoff offset, seek_dir origin );

Streamoff is defined in iostream. H, and defines the maximum value that can be obtained by Offset offset. seek_dir indicates the reference position for moving and is an enumeration with the following values:

IOS: Beg: Start of the file
IOS: cur: current file location
IOS: end: End of the file
These two functions are generally used in binary files, because text files may be different from the expected values due to the system's interpretation of characters.

Example:

File1.seekg (1234, IOS: cur); // move the read pointer of the file from the current position to the back of the 1234 bytes
File2.seekp (1234, IOS: Beg); // transfers the write pointer of the object from the beginning to the back of the object by 1234 bytes.

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------

Winapi-based file operations
Winapi provides two file operation functions, one for compatibility with 16-bit programs, which is relatively simple; the other for 32-bit programs, these two groups of functions are described as follows:

1. A group of functions compatible with 16-bit programs

(1) _ lopen
Prototype: hfile _ lopen (
Lpcstr lppathname, // file name
Int ireadwrite // File Access Method
);

Function: open the file and return its handle. similar to this, there is an openfile () function. You can view the Help file on your own.

Parameter description: lppathname is the name of the file to be opened, and ireadwrite is a file access method. There are three main methods:

Of_read: open in read-only mode
Of_readwrite: open in read/write mode
Of_write: open in write-only mode
Also, attributes such as of_share_compat are not described here because they are not commonly used.

(2) _ lclose ()
Prototype: hfile _ lclose (hfile );

Function: Close the file. 0 is returned if the file is successfully closed.

Parameter description: hfile: handle to be closed

(3) _ lread ()
Prototype: uint _ lread (hfile, // file handle
Lpvoid lpbuffer, // buffer for storing data
Uint ubytes // The length to be read
);

Function: reads a file and returns the number of characters actually read. Like this, there is also a _ hread () function. You can view the Help file on your own.

(4) _ lwrite ()
Prototype: uint _ lwrite (hfile, // file handle
Lpstr lpbuffer, // buffer for storing data
Uint ubytes // The length to be written
);

Function: writes a file and returns the number of characters actually written. Like this, there is also a _ hwrite () function. You can view the Help file on your own.

Vertex _ llseek ()
Prototype: long _ llseek (hfile, // file handle
Long loffset, // The amount of movement
Int iorigin // reference position for moving
);

Function: Move the read/write location of a file. The read/write location of the moved file is returned successfully.

Parameter description: iorigin has the following values:

File_begin: File Header
File_current: current file location
File_end: End of the file
Authorization _ lcreat ()
Prototype: hfile _ lcreat (lpcstr lppathname, // file name to be created
Int iattribute // file attributes
);

Function: Creates a file and returns its handle.

Parameter description: The file attributes are the sum of the following values:

0: Common File
1: Read-Only files
2: Implicit File
4: system files
The usage of these functions is similar to that of the listed BCB database functions. We recommend that you use the database functions of BCB. For more information, see File Operations Based on BCB library functions.

2. 32-bit program compatibility

Createfile
Open a file
To read and write a file, you must first obtain the file handle. This function can be used to obtain the file handle, which is the door to the file world.

Readfile
Read byte information from a file.
After opening the file and obtaining the file handle, you can use this function to read data.

Writefile
Write byte information to the file.
You can also pass the file handle to this function to Write File data.

Closehandle
Close the file handle.
After opening the door, remember to close it.

Getfiletime
Obtain the file time.
There are three file time options: creation time, last access time, and last write time.
This function also requires the file handle as the entry parameter.

Getfilesize
Obtain the file size.
Because the file size can be as high as several GB (1 GB requires 30 bits), a 32-bit dubyte type cannot be accurately expressed, so the return code is 32 bits, there is also an exit parameter that can output a 32-bit high.
This function also requires the file handle as the entry parameter.

Getfileattributes
Obtain file attributes.
You can obtain attributes such as archive, read-only, system, and hide.
This function uses only one file path as the parameter.

Setfileattributes
Set file properties.
Can be obtained, and should also be set.
You can set attributes such as archive, read-only, system, and hide.
This function uses only one file path as the parameter.

Getfileinformationbyhandle
Get all file information
This function can obtain the information that all functions above can obtain, such as the size and attribute. It also contains information that cannot be obtained from other places, such as file volume tag, index, and link information.
This function requires the file handle as the entry parameter.

Getfullpathname
Obtain the file path. This function obtains the complete path name of the file.
Note that the result is correct only when the file is in the current directory. If you want to get the real path. Use the getmodulefilename function.

Copyfile
Copy a file
Note: Only files can be copied, but directories cannot be copied.

Movefileex
Move files
You can move files or directories, but not across drive letters. (You can set a move flag in Windows to span the drive letter)

Deletefile
Delete an object

Gettemppath
Obtain the Windows temporary directory path

Gettempfilename
Create a unique temporary file under the Windows temporary directory path

Setfilepoint
Move the file pointer.
This function is used to perform advanced read/write operations on files.

File Locking and unlocking

Lockfile
Unlockfile
Lockfileex
Unlockfileex

The above four functions are used to lock and unlock the file. In this way, asynchronous file operations can be implemented. You can perform operations on different parts of the file at the same time.

File compression and decompression

Lzopenfile
Open the compressed file to read

Lzseek
Find a location in the compressed file

Lzread
Read a compressed file

Lzclose
Close a compressed file

Lzcopy
Copy the compressed file and expand it during processing

Getexpandedname
Returns the file name from the compressed file.

The above six functions are a small extension library in the 32-bit API, and the functions in the File compression extension library. You can use the compress command to Create File compression.

File image/ ing

The 32-bit API provides a feature called file image/ ing that allows you to map files directly to the virtual memory space of an application. This technology can be used to simplify and accelerate file access.

Createfilemapping
Create and name ing

Mapviewoffile
Load file ing like memory

Unmapviewoffile
Release the view and write the changes back to the file

Flushviewoffile
Refresh view changes to disk

Related Article

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.