How do you access and modify the time stamps of the file?explain the prototype and write a program to illustrate the usage of prototype?
Answers
Answered by
0
This chapter describes the GNU C library's functions for manipulating files. Unlike the input and output functions (see section Input/Output on Streams; see section Low-Level Input/Output), these functions are concerned with operating on the files themselves rather than on their contents.
Among the facilities described in this chapter are functions for examining or modifying directories, functions for renaming and deleting files, and functions for examining and setting file attributes such as access permissions and modification times.
Working Directory
Each process has associated with it a directory, called its current working directory or simply working directory, that is used in the resolution of relative file names (see section File Name Resolution).
When you log in and begin a new session, your working directory is initially set to the home directory associated with your login account in the system user database. You can find any user's home directory using the getpwuid or getpwnam functions; see section User Database.
Users can change the working directory using shell commands like cd. The functions described in this section are the primitives used by those commands and by other programs for examining and changing the working directory.
Prototypes for these functions are declared in the header file `unistd.h'.
Function: char * getcwd (char *buffer, size_t size)The getcwd function returns an absolute file name representing the current working directory, storing it in the character array buffer that you provide. The size argument is how you tell the system the allocation size of buffer.
The GNU library version of this function also permits you to specify a null pointer for the buffer argument. Then getcwdallocates a buffer automatically, as with malloc (see section Unconstrained Allocation). If the size is greater than zero, then the buffer is that large; otherwise, the buffer is as large as necessary to hold the result.
The return value is buffer on success and a null pointer on failure. The following errno error conditions are defined for this function:
Among the facilities described in this chapter are functions for examining or modifying directories, functions for renaming and deleting files, and functions for examining and setting file attributes such as access permissions and modification times.
Working Directory
Each process has associated with it a directory, called its current working directory or simply working directory, that is used in the resolution of relative file names (see section File Name Resolution).
When you log in and begin a new session, your working directory is initially set to the home directory associated with your login account in the system user database. You can find any user's home directory using the getpwuid or getpwnam functions; see section User Database.
Users can change the working directory using shell commands like cd. The functions described in this section are the primitives used by those commands and by other programs for examining and changing the working directory.
Prototypes for these functions are declared in the header file `unistd.h'.
Function: char * getcwd (char *buffer, size_t size)The getcwd function returns an absolute file name representing the current working directory, storing it in the character array buffer that you provide. The size argument is how you tell the system the allocation size of buffer.
The GNU library version of this function also permits you to specify a null pointer for the buffer argument. Then getcwdallocates a buffer automatically, as with malloc (see section Unconstrained Allocation). If the size is greater than zero, then the buffer is that large; otherwise, the buffer is as large as necessary to hold the result.
The return value is buffer on success and a null pointer on failure. The following errno error conditions are defined for this function:
Similar questions