add io_readwritefile, io_appendfile
parent
11f0616cf3
commit
696c5f872c
@ -0,0 +1,16 @@
|
|||||||
|
.TH io_appendfile 3
|
||||||
|
.SH NAME
|
||||||
|
io_appendfile \- open a file for appending
|
||||||
|
.SH SYNTAX
|
||||||
|
.B #include <io.h>
|
||||||
|
|
||||||
|
int \fBio_appendfile\fP(int64* d,const char* s);
|
||||||
|
.SH DESCRIPTION
|
||||||
|
io_appendfile sets d to the number of a new descriptor writing to the
|
||||||
|
end of the disk file named \fIs\fR, and returns 1. If the file does not
|
||||||
|
exist, it will be created with mode 0600.
|
||||||
|
|
||||||
|
If something goes wrong, io_appendfile sets \fIerrno\fR to indicate the error, and
|
||||||
|
returns 0; it does not create a new descriptor, and it does not touch d.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
io_readfile(3), io_createfile(3), io_readwritefile(3)
|
@ -0,0 +1,13 @@
|
|||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include "io_internal.h"
|
||||||
|
|
||||||
|
int io_appendfile(int64* d,const char* s) {
|
||||||
|
long fd=open(s,O_WRONLY|O_APPEND|O_CREAT,0600);
|
||||||
|
if (fd != -1) {
|
||||||
|
*d=fd;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
.TH io_readwritefile 3
|
||||||
|
.SH NAME
|
||||||
|
io_readfile \- open a file for reading and writing
|
||||||
|
.SH SYNTAX
|
||||||
|
.B #include <io.h>
|
||||||
|
|
||||||
|
int \fBio_readwritefile\fP(int64* d,const char* s);
|
||||||
|
.SH DESCRIPTION
|
||||||
|
io_readwritefile sets d to the number of a new descriptor reading from
|
||||||
|
and writing to the disk file named \fIs\fR, and returns 1. The file
|
||||||
|
needs to exist.
|
||||||
|
|
||||||
|
If something goes wrong, io_readwritefile sets \fIerrno\fR to indicate the error, and
|
||||||
|
returns 0; it does not create a new descriptor, and it does not touch d.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
io_readfile(3), io_createfile(3), io_appendfile(3)
|
@ -0,0 +1,13 @@
|
|||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include "io_internal.h"
|
||||||
|
|
||||||
|
int io_readwritefile(int64* d,const char* s) {
|
||||||
|
long fd=open(s,O_RDWR);
|
||||||
|
if (fd != -1) {
|
||||||
|
*d=fd;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue