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