Function
r+ Open an 9r.isting file for update (reading and writing).
w+ Create a new file for update (reading and writing). If a file by that name already exists, it will be overwritten.
a+ Open for appand; open for update at the end of the file, or create if the file does not exist.
To specify that a given file is being opened or created in text mode, append a t to the mode string (rt, w+t, and so on). Similarly, to specify binary mode, . append a b to the mode string (wb, a+b, and so on).'Jsopen also allows the t
or b to be inserted betwee'n the letter and the + character in the mode string;
for example, rt+ is equivalent to r+t.
If a t or b is not given in the mode string, the mode is governed by the global variable Jmode. If Jmode is set to a_BINARY, files are opened in binary mode. If Jmode is set to a_TEXT, they are opened in text mode. These 0_ ...
constants are defined in fcntl.h.
When a file is opened for update, both input and output can be done on the resulting stream. However, output cannot be followed directly by input without an intervening fseekor rewind, and input cannot be directly followed by output without an intervening fseek, rewind, or an input that encounters end-of-file.
shflag specifies the type of file-sharing allowed on the file filename. Symbolic constants for shflag are defined in share.h.' '
Value of shflag SH_COMPAT SH_DENYRW SH_DENYWR SH_DENYRD SH_DENYNONE SH_DENYNO
Description
Sets compatibility mode Denies read/write access Denies write access Denies read access Permits read/write access Permits read/write access
On successful completion, Jsopen returns a pointer to the newly opened stream. In the event of error, it returns NULL.
creat, _dos_open, dup, fclose, fdopen, ferror, Jmode (global variable), fopen, fread, freopen, fseek, fwrite, open, rewind, setbuf, setmode, sopen
sys\stat.h
Gets open file information.
Syntax
Remarks
int fstat(int handle, struct stat *statbuf);
int stat(char *path, struct stat *statbuf);
fstat, stat
fstat stores information in the stat structure about the file or directory
associated with handle. '
stat stores information about a given file or directory in the stat structure.
The name of the file is path.
statbufpoints to the stat structure (defined in sys\stat.h). That structure contains the following fields:
st_mode Bit mask givfug information about the file's mode
st_dev Drive number of disk containing the file, or file handle if the file is on a device
st_rdev Same as st_dev
st_nlink Set to the integer constant 1 st_size Size of the file in bytes st_atime Most recent access st_mtime Same as st_atime st_ctime Same as st_atime
The stat structure contains three more fields not mentioned here. They contain values that are meaningful only in UNIX.
The st_mode bit mask that gives information about the mode of the open file includes the following bits:
One of the following bits will be set:
S_IFCHR If handle refers to a device.
S_IFREG If an ordinary file is referred to by handle.
One or both of the following bits will be set:
S_IWRITE If user has permission to write to file.
S_IREAD If user has permission to read to file.
The HPFS and NTFS file-management systems make the following distinctions:
fstat, stat
Return value
See also
Function Syntax
Remarks
Note that when a far string function returns an int or size_t, the return is never modified by the far keyword.
Return value See also
ftell
Function Syntax
st_atime Most recent access.
st_mtime Most recent modify.
st_ctime Creation time.
fstat and stat return 0 if they successfully retrieved the information about the open file. On error (failure to get the information), these functions return ....:1 and set the global variable errno to
EBADF Bad file handle access, chmod
string.h
Provides string operations in a large-code model.
far string functions
The See also section below provides a list of string functions that have a far version. The far version of a string function is prefixed with Jstr. The behavior of a far string function is identical to the behavior of the standard function to which it corresponds. The only difference is that for a far string function, the arguments and return value (only when the return value is of type 'char far *') are each modified by the far keyword. The entry for each of the functions provides a description that applies to the far version. -When an Jstr-type function returns a char pointer, the return is a far type.
strcat, strchr, strcmp, strcpy, strcspn, strdup, stricmp, strlen, strlwr, strncat, strncmp, strncpy, strnicmp, strnset, strpbrk, strrchr, strrev, strset, strspn, strstr,
strtok, strupr '
stdio.h
-Returns the current file pointer.
long int ftell(FILE *stream);
Remarks '
Return value
See also
ftime
Function Syntax
Remarks
ftell
ftell returns the current file pointer.for stream. The offset is measured in , bytes from the beginning of the file (if the file is binary). The value returned
by ftell can be used in a subsequent call to fseek.
ftell returns the current file pointer position on success. It returns -lL on error and sets the global variable errno to a positive value.
In the event of an error return, the global variable errno is set to one of the following values:
EBADF Bad file pointer ESPIPE Illegal seek on device fgetpos, fseek,fsetpos, lseek, rewind, tell