doc
c_file.h
Go to the documentation of this file.
1/*
2 * cynapses libc functions
3 *
4 * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
5 * Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file c_file.h
24 *
25 * @brief Interface of the cynapses libc file function
26 *
27 * @defgroup cynFileInternals cynapses libc file functions
28 * @ingroup cynLibraryAPI
29 *
30 * @{
31 */
32
33#ifndef _C_FILE_H
34#define _C_FILE_H
35
36#include <sys/types.h>
37#include <stdio.h>
38
39#ifndef BUFFER_SIZE
40#define BUFFER_SIZE (16 * 1024)
41#endif
42
43/**
44 * @brief Check if a path is a regular file or a link.
45 *
46 * @param path The path to check.
47 *
48 * @return 1 if the path is a file, 0 if the path doesn't exist, is a
49 * something else or can't be accessed.
50 */
51int c_isfile(const char *path);
52
53/**
54 * @brief copy a file from source to destination.
55 *
56 * @param src Path to the source file
57 * @param dst Path to the destination file
58 * @param mode File creation mode of the destination. If mode is 0 then the
59 * mode from the source will be used.
60 *
61 * @return 0 on success, less than 0 on error with errno set.
62 * EISDIR if src or dst is a file.
63 */
64int c_copy(const char *src, const char *dst, mode_t mode);
65
66/**
67 * @brief Compare the content of two files byte by byte.
68 * @param f1 Path of file 1
69 * @param f2 Path of file 2
70 *
71 * @return 0 if the files differ, 1 if the files are equal or -1 on
72 * error with errno set.
73 */
74int c_compare_file( const char *f1, const char *f2 );
75
76/**
77 * @brief move a file from source to destination.
78 *
79 * @param src Path to the source file
80 * @param dst Path to the destination file
81 *
82 * @return 0 on success, less than 0 on error with errno set.
83 */
84int c_rename( const char *src, const char *dst );
85
86/**
87 * }@
88 */
89#endif /* _C_FILE_H */
90
char path[1]
Definition: csync_private.h:11
mode_t mode
Definition: csync_private.h:7
int c_rename(const char *src, const char *dst)
move a file from source to destination.
int c_compare_file(const char *f1, const char *f2)
Compare the content of two files byte by byte.
int c_isfile(const char *path)
Check if a path is a regular file or a link.
int c_copy(const char *src, const char *dst, mode_t mode)
copy a file from source to destination.