global: convert indentation-TABs to spaces
[coreutils.git] / src / remove.h
blobed1a0214e49b20e919adb559cc8c38ead1fd8ca4
1 /* Remove directory entries.
3 Copyright (C) 1998, 2000, 2002, 2003-2009 Free Software Foundation, Inc.
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 <http://www.gnu.org/licenses/>. */
18 #ifndef REMOVE_H
19 # define REMOVE_H
21 # include "dev-ino.h"
23 enum rm_interactive
25 /* Start with any number larger than 1, so that any legacy tests
26 against values of 0 or 1 will fail. */
27 RMI_ALWAYS = 3,
28 RMI_SOMETIMES,
29 RMI_NEVER
32 struct rm_options
34 /* If true, ignore nonexistent files. */
35 bool ignore_missing_files;
37 /* If true, query the user about whether to remove each file. */
38 enum rm_interactive interactive;
40 /* If true, do not traverse into (or remove) any directory that is
41 on a file system (i.e., that has a different device number) other
42 than that of the corresponding command line argument. Note that
43 even without this option, rm will fail in the end, due to its
44 probable inability to remove the mount point. But there, the
45 diagnostic comes too late -- after removing all contents. */
46 bool one_file_system;
48 /* If true, recursively remove directories. */
49 bool recursive;
51 /* Pointer to the device and inode numbers of `/', when --recursive
52 and preserving `/'. Otherwise NULL. */
53 struct dev_ino *root_dev_ino;
55 /* If nonzero, stdin is a tty. */
56 bool stdin_tty;
58 /* If true, display the name of each file removed. */
59 bool verbose;
61 /* If true, treat the failure by the rm function to restore the
62 current working directory as a fatal error. I.e., if this field
63 is true and the rm function cannot restore cwd, it must exit with
64 a nonzero status. Some applications require that the rm function
65 restore cwd (e.g., mv) and some others do not (e.g., rm,
66 in many cases). */
67 bool require_restore_cwd;
70 enum RM_status
72 /* These must be listed in order of increasing seriousness. */
73 RM_OK = 2,
74 RM_USER_DECLINED,
75 RM_ERROR,
76 RM_NONEMPTY_DIR
79 # define VALID_STATUS(S) \
80 ((S) == RM_OK || (S) == RM_USER_DECLINED || (S) == RM_ERROR)
82 # define UPDATE_STATUS(S, New_value) \
83 do \
84 { \
85 if ((New_value) == RM_ERROR \
86 || ((New_value) == RM_USER_DECLINED && (S) == RM_OK)) \
87 (S) = (New_value); \
88 } \
89 while (0)
91 enum RM_status rm (size_t n_files, char const *const *file,
92 struct rm_options const *x);
94 #endif