Linux Programming---file operations

Source: Internet
Author: User

System functions for file operations:

Open function, close function, read function, write function, getcwd function, Access function, stat function, Fstat function, GETCWD function

Function Prototypes:

1:open function

Function: Open an existing file, or create a new file and open:, the successful return value is the file identification number, the failure is-1

Parameter: Parhname is the file path, the flag ID is preferable to the following value

Mode indicates file access permissions

2:close function

Function: Close file operation, return value indicates whether successful

Parameters: File identification number

3:read function

Function: Read the contents of the file, the return value indicates the actual read content size, failure will return 1

Parameters: FD file identification number; Buff indicates read-in content; count content size;

4:write function

Function: Write the contents of the file, the return value indicates the actual write content size, failed to return 1;

Parameters: FD file identification number; Buff indicates read-in content; count content size;

5:access function

Function: Used to determine whether a certain operation can be done, is to return 0, otherwise return-1

Parameter: Parhname represents the file path, mode indicates that the operation is as follows:

6:stat function Fstat function

Function: The same as the function is to view the file properties

Parameters: Stat is used to obtain an open file through a file path, Fstat is used to open a file that has been opened with a file identification number to obtain;

The second parameter stat struct pointer is used to store file attribute values.

Note: The stat structure is as follows:

7:GETCWD function

Function: get current directory; error return-1;

Parameters: Buff is used to store the obtained road strength; size is used to store buff sizes

function use:

Cond

Linux Programming---file operations

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.