mirror of
https://github.com/troglobit/libite.git
synced 2026-10-11 17:02:26 +07:00
fsendfile(): Break ABI by switching src and dst to match rest of API.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -63,6 +63,11 @@ Generic Functions
|
||||
names: files and directories that must be freed after use. See
|
||||
the unit test at the bottom for an example.
|
||||
|
||||
- `fcopyfile(src, dst)`
|
||||
|
||||
Like `copyfile()` but uses already open `FILE *` pointers. Copies
|
||||
from current file positions to current file positions until EOF.
|
||||
|
||||
- `fexist(file)`
|
||||
|
||||
Check for the existance of a file, returns True(1) or False(0).
|
||||
@@ -75,6 +80,18 @@ Generic Functions
|
||||
|
||||
Returns the `mode_t` bits of a file or directory.
|
||||
|
||||
- `fsendfile(src, dst, len)`
|
||||
|
||||
Copy data between file streams, very similar to `fcopyfile()`, but
|
||||
`dst` is allowed to be `NULL` to be able to read and discard `len`
|
||||
bytes from `src`.
|
||||
|
||||
- `movefile(src, dst)`
|
||||
|
||||
Like `copyfile()`, but renames `src` to `dst`, or recreates symlink
|
||||
with the `dst` name. On successful operation the source is removed
|
||||
and the function returns POSIX OK (0).
|
||||
|
||||
- `rsync(src, dst, delete, *filter())`
|
||||
|
||||
Very simple `rsync()` to copy files files and directories
|
||||
|
||||
+3
-3
@@ -28,8 +28,8 @@
|
||||
|
||||
/**
|
||||
* fsendfile - copy data between file streams
|
||||
* @dst: Destination stream
|
||||
* @src: Source stream
|
||||
* @dst: Destination stream
|
||||
* @len: Number of bytes to copy
|
||||
*
|
||||
* @dst may be %NULL, in which case @len bytes are read and discarded
|
||||
@@ -41,7 +41,7 @@
|
||||
* The number of bytes copied. If an error is detected -1 is returned
|
||||
* and @errno will be set accordingly.
|
||||
*/
|
||||
size_t fsendfile(FILE *dst, FILE *src, size_t len)
|
||||
size_t fsendfile(FILE *src, FILE *dst, size_t len)
|
||||
{
|
||||
char *buf;
|
||||
size_t blk = BUFSIZ, num = 0, tot = 0;
|
||||
@@ -94,7 +94,7 @@ int main(void)
|
||||
src = fopen(files[i], "r");
|
||||
dst = fopen(files[i + 1], "w");
|
||||
fprintf(stderr, "fsendfile(%s, %s, 512)\t", files[i], files[i + 1]);
|
||||
if (-1 == fsendfile(dst, src, 512))
|
||||
if (-1 == fsendfile(src, dst, 512))
|
||||
perror("Failed");
|
||||
|
||||
if (!access(files[i + 1], F_OK))
|
||||
|
||||
@@ -43,7 +43,7 @@ FILE *tempfile (void);
|
||||
ssize_t copyfile (char *src, char *dst, int len, int sym);
|
||||
int movefile (char *src, char *dst);
|
||||
int fcopyfile (FILE *src, FILE *dst);
|
||||
size_t fsendfile (FILE *out, FILE *in, size_t sz);
|
||||
size_t fsendfile (FILE *src, FILE *dst, size_t len);
|
||||
|
||||
int dir (const char *dir, const char *type, int (*filter) (const char *file), char ***list, int strip);
|
||||
int rsync (char *src, char *dst, int delete, int (*filter) (const char *file));
|
||||
|
||||
Reference in New Issue
Block a user