xstrtol-error: pacify -Wswitch-enum
[gnulib.git] / lib / copy-file.h
blob3393eac0c86599ef33e635324e7879e2b82238fa
1 /* Copying of files.
2 Copyright (C) 2001-2003, 2009-2025 Free Software Foundation, Inc.
3 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19 /* This file uses _GL_ATTRIBUTE_DEPRECATED. */
20 #if !_GL_CONFIG_H_INCLUDED
21 #error "Please include config.h first."
22 #endif
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
29 /* Error codes returned by qcopy_file_preserving or copy_file_to. */
30 enum
32 GL_COPY_ERR_OPEN_READ = -1,
33 GL_COPY_ERR_OPEN_BACKUP_WRITE = -2,
34 GL_COPY_ERR_READ = -3,
35 GL_COPY_ERR_WRITE = -4,
36 GL_COPY_ERR_AFTER_READ = -5,
37 GL_COPY_ERR_GET_ACL = -6,
38 GL_COPY_ERR_SET_ACL = -7
42 /* Copy a regular file: from src_filename to dest_filename.
43 The destination file is assumed to be a backup file.
44 Modification times, owner, group and access permissions are preserved as
45 far as possible (similarly to what 'cp -p SRC DEST' would do).
46 Return 0 if successful, otherwise set errno and return one of the error
47 codes above. */
48 extern int qcopy_file_preserving (const char *src_filename, const char *dest_filename);
50 /* Copy a regular file: from src_filename to dest_filename.
51 The destination file is assumed to be a backup file.
52 Modification times, owner, group and access permissions are preserved as
53 far as possible (similarly to what 'cp -p SRC DEST' would do).
54 Exit upon failure. */
55 extern void xcopy_file_preserving (const char *src_filename, const char *dest_filename);
57 /* Old name of xcopy_file_preserving. */
58 _GL_ATTRIBUTE_DEPRECATED void copy_file_preserving (const char *src_filename, const char *dest_filename);
61 /* Copy a regular file: from src_filename to dest_filename.
62 The source file is assumed to be not confidential.
63 Modification times, owner, group and access permissions of src_filename
64 are *not* copied over to dest_filename (similarly to what 'cat SRC > DEST'
65 would do; if DEST already exists, this is the same as what 'cp SRC DEST'
66 would do.)
67 Return 0 if successful, otherwise set errno and return one of the error
68 codes above. */
69 extern int copy_file_to (const char *src_filename, const char *dest_filename);
71 /* Copy a regular file: from src_filename to dest_filename.
72 The source file is assumed to be not confidential.
73 Modification times, owner, group and access permissions of src_filename
74 are *not* copied over to dest_filename (similarly to what 'cat SRC > DEST'
75 would do; if DEST already exists, this is the same as what 'cp SRC DEST'
76 would do.)
77 Exit upon failure. */
78 extern void xcopy_file_to (const char *src_filename, const char *dest_filename);
81 #ifdef __cplusplus
83 #endif