blob: 5f3bdc6ab2dd263a15fa5615a15b678561ee5bc2 [file] [log] [blame]
Alistair Delvabeaee832021-02-24 11:27:23 -08001#ifndef MTOOLS_NAMECLASH_H
2#define MTOOLS_NAMECLASH_H
3
4/* Copyright 1996-1998,2000-2002,2008,2009 Alain Knaff.
5 * This file is part of mtools.
6 *
7 * Mtools is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Mtools 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "stream.h"
22
23typedef enum clash_action {
24 NAMEMATCH_NONE,
25 NAMEMATCH_AUTORENAME,
26 NAMEMATCH_QUIT,
27 NAMEMATCH_SKIP,
28 NAMEMATCH_RENAME,
29 NAMEMATCH_PRENAME, /* renaming of primary name */
30 NAMEMATCH_OVERWRITE,
31 NAMEMATCH_ERROR,
32 NAMEMATCH_SUCCESS,
33 NAMEMATCH_GREW
34} clash_action;
35
36/* clash handling structure */
37typedef struct ClashHandling_t {
38 clash_action action[2];
39 clash_action namematch_default[2];
Yi Kong39bbd962022-01-09 19:41:38 +080040
Alistair Delvabeaee832021-02-24 11:27:23 -080041 int nowarn; /* Don't ask, just do default action if name collision*/
42 int got_slots;
43 int mod_time;
44 /* unsigned int dot; */
45 char *myname;
46 unsigned char *dosname;
47 int single;
48
49 int use_longname;
50 int ignore_entry;
51 int source; /* to prevent the source from overwriting itself */
Yi Kong39bbd962022-01-09 19:41:38 +080052 int source_entry; /* to account for the space freed up by the original
53 * name */
Alistair Delvabeaee832021-02-24 11:27:23 -080054 void (*name_converter)(doscp_t *cp,
Yi Kong39bbd962022-01-09 19:41:38 +080055 const char *filename, int verbose,
Alistair Delvabeaee832021-02-24 11:27:23 -080056 int *mangled, dos_name_t *ans);
57 int is_label;
58} ClashHandling_t;
59
60/* write callback */
61typedef int (write_data_callback)(dos_name_t *,char *, void *, struct direntry_t *);
62
63int mwrite_one(Stream_t *Dir,
64 const char *argname,
65 const char *shortname,
66 write_data_callback *cb,
67 void *arg,
68 ClashHandling_t *ch);
69
70int handle_clash_options(ClashHandling_t *ch, char c);
71void init_clash_handling(ClashHandling_t *ch);
72Stream_t *createDir(Stream_t *Dir, const char *filename, ClashHandling_t *ch,
73 unsigned char attr, time_t mtime);
74
75
76#endif