version 7.3
[coreutils.git] / src / remove.h
blob8f14d06ab6ebea3f3cf35bee076de1de50d41245
1 /* Remove directory entries.
3 Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free
4 Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef REMOVE_H
20 # define REMOVE_H
22 # include "dev-ino.h"
24 enum rm_interactive
26 /* Start with any number larger than 1, so that any legacy tests
27 against values of 0 or 1 will fail. */
28 RMI_ALWAYS = 3,
29 RMI_SOMETIMES,
30 RMI_NEVER
33 struct rm_options
35 /* If true, ignore nonexistent files. */
36 bool ignore_missing_files;
38 /* If true, query the user about whether to remove each file. */
39 enum rm_interactive interactive;
41 /* If true, do not traverse into (or remove) any directory that is
42 on a file system (i.e., that has a different device number) other
43 than that of the corresponding command line argument. Note that
44 even without this option, rm will fail in the end, due to its
45 probable inability to remove the mount point. But there, the
46 diagnostic comes too late -- after removing all contents. */
47 bool one_file_system;
49 /* If true, recursively remove directories. */
50 bool recursive;
52 /* Pointer to the device and inode numbers of `/', when --recursive
53 and preserving `/'. Otherwise NULL. */
54 struct dev_ino *root_dev_ino;
56 /* If nonzero, stdin is a tty. */
57 bool stdin_tty;
59 /* If true, display the name of each file removed. */
60 bool verbose;
62 /* If true, treat the failure by the rm function to restore the
63 current working directory as a fatal error. I.e., if this field
64 is true and the rm function cannot restore cwd, it must exit with
65 a nonzero status. Some applications require that the rm function
66 restore cwd (e.g., mv) and some others do not (e.g., rm,
67 in many cases). */
68 bool require_restore_cwd;
71 enum RM_status
73 /* These must be listed in order of increasing seriousness. */
74 RM_OK = 2,
75 RM_USER_DECLINED,
76 RM_ERROR,
77 RM_NONEMPTY_DIR
80 # define VALID_STATUS(S) \
81 ((S) == RM_OK || (S) == RM_USER_DECLINED || (S) == RM_ERROR)
83 # define UPDATE_STATUS(S, New_value) \
84 do \
85 { \
86 if ((New_value) == RM_ERROR \
87 || ((New_value) == RM_USER_DECLINED && (S) == RM_OK)) \
88 (S) = (New_value); \
89 } \
90 while (0)
92 enum RM_status rm (size_t n_files, char const *const *file,
93 struct rm_options const *x);
95 #endif