1/*
2 * Copyright (c) 2006 Apple Computer, Inc.  All rights reserved.
3 */
4
5#ifndef __REMOVEFILE_H__
6#define __REMOVEFILE_H__
7
8#include <stdint.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/*
15 * Flags
16 */
17typedef uint32_t removefile_flags_t;
18
19enum {
20	REMOVEFILE_RECURSIVE = (1 << 0),			// If path is a directory, recurse (depth first traversal)
21	REMOVEFILE_KEEP_PARENT = (1 << 1),			// Remove contents but not directory itself
22	REMOVEFILE_SECURE_7_PASS = (1 << 2),		// 7 pass DoD algorithm
23	REMOVEFILE_SECURE_35_PASS  = (1 << 3),	// 35-pass Gutmann algorithm (overrides REMOVEFILE_SECURE_7_PASS)
24	REMOVEFILE_SECURE_1_PASS = (1 << 4),	// 1 pass single overwrite
25	REMOVEFILE_SECURE_3_PASS = (1 << 5),	// 3 pass overwrite
26	REMOVEFILE_SECURE_1_PASS_ZERO = (1 << 6),	// Single-pass overwrite, with 0 instead of random data
27};
28
29/*
30 * State object to pass in callback information
31 */
32typedef struct _removefile_state * removefile_state_t;
33
34removefile_state_t removefile_state_alloc(void);
35int removefile_state_free(removefile_state_t);
36
37int removefile_state_get(removefile_state_t state, uint32_t key, void * dst);
38int removefile_state_set(removefile_state_t state, uint32_t key, const void* value);
39
40enum {
41	REMOVEFILE_STATE_CONFIRM_CALLBACK = 1,	// removefile_callback_t
42	REMOVEFILE_STATE_CONFIRM_CONTEXT = 2,		// void*
43	REMOVEFILE_STATE_ERROR_CALLBACK = 3,		// removefile_callback_t
44	REMOVEFILE_STATE_ERROR_CONTEXT = 4,		// void*
45	REMOVEFILE_STATE_ERRNO = 5,					// int (read-only)
46	REMOVEFILE_STATE_STATUS_CALLBACK = 6,		// removefile_callback_t
47	REMOVEFILE_STATE_STATUS_CONTEXT = 7,		// void*
48};
49
50typedef int (*removefile_callback_t)(removefile_state_t state, const char* path, void* context);
51
52/*
53 * Callback return values
54 */
55enum {
56	REMOVEFILE_PROCEED = 0,
57	REMOVEFILE_SKIP = 1,
58	REMOVEFILE_STOP = 2,
59};
60
61
62int removefile(const char* path, removefile_state_t state, removefile_flags_t flags);
63
64int removefile_cancel(removefile_state_t state);
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif /* __REMOVEFILE_H__ */
71