Updated italian translation
[midnight-commander.git] / src / filenot.c
blobf614ce1e6fead898262ac1b44313e76bd592708b
1 /*
2 filenot.c: wrapper for routines to notify the
3 tree about the changes made to the directory
4 structure.
6 Author:
7 Janne Kukonlehto
8 Miguel de Icaza
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include <config.h>
27 #include <errno.h>
28 #include <string.h>
30 #include "global.h"
32 static char *
33 get_absolute_name (const char *file)
35 char dir[MC_MAXPATHLEN];
37 if (file[0] == PATH_SEP)
38 return g_strdup (file);
39 mc_get_current_wd (dir, MC_MAXPATHLEN);
40 return concat_dir_and_file (dir, file);
43 static int
44 my_mkdir_rec (char *s, mode_t mode)
46 char *p, *q;
47 int result;
49 if (!mc_mkdir (s, mode))
50 return 0;
51 else if (errno != ENOENT)
52 return -1;
54 /* FIXME: should check instead if s is at the root of that filesystem */
55 if (!vfs_file_is_local (s))
56 return -1;
58 if (!strcmp (s, PATH_SEP_STR)) {
59 errno = ENOTDIR;
60 return -1;
63 p = concat_dir_and_file (s, "..");
64 q = vfs_canon (p);
65 g_free (p);
67 if (!(result = my_mkdir_rec (q, mode)))
68 result = mc_mkdir (s, mode);
70 g_free (q);
71 return result;
74 int
75 my_mkdir (const char *s, mode_t mode)
77 int result;
78 char *my_s;
80 result = mc_mkdir (s, mode);
81 if (result) {
82 char *p = vfs_canon (s);
84 result = my_mkdir_rec (p, mode);
85 g_free (p);
87 if (result == 0) {
88 my_s = get_absolute_name (s);
90 #ifdef FIXME
91 tree_add_entry (tree, my_s);
92 #endif
94 g_free (my_s);
96 return result;
99 int
100 my_rmdir (const char *s)
102 int result;
103 char *my_s;
104 #ifdef FIXME
105 WTree *tree = 0;
106 #endif
108 /* FIXME: Should receive a Wtree! */
109 result = mc_rmdir (s);
110 if (result == 0) {
111 my_s = get_absolute_name (s);
113 #ifdef FIXME
114 tree_remove_entry (tree, my_s);
115 #endif
117 g_free (my_s);
119 return result;