Changes in sources matched with movement of $(srcdir)/vfs into $(srcdir)/lib/vfs...
[pantumic.git] / src / filenot.c
blobd702e466fb86231e3721896140c09f468a064ddc
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.
26 /** \file filenot.c
27 * \brief Source: wrapper for routines to notify the
28 * tree about the changes made to the directory
29 * structure.
32 #include <config.h>
34 #include <errno.h>
35 #include <string.h>
37 #include "global.h"
38 #include "fs.h"
39 #include "util.h"
41 #include "../../lib/vfs/mc-vfs/vfs.h"
43 static char *
44 get_absolute_name (const char *file)
46 char dir[MC_MAXPATHLEN];
48 if (file[0] == PATH_SEP)
49 return g_strdup (file);
50 mc_get_current_wd (dir, MC_MAXPATHLEN);
51 return concat_dir_and_file (dir, file);
54 static int
55 my_mkdir_rec (char *s, mode_t mode)
57 char *p, *q;
58 int result;
60 if (!mc_mkdir (s, mode))
61 return 0;
62 else if (errno != ENOENT)
63 return -1;
65 /* FIXME: should check instead if s is at the root of that filesystem */
66 if (!vfs_file_is_local (s))
67 return -1;
69 if (!strcmp (s, PATH_SEP_STR)) {
70 errno = ENOTDIR;
71 return -1;
74 p = concat_dir_and_file (s, "..");
75 q = vfs_canon (p);
76 g_free (p);
78 if (!(result = my_mkdir_rec (q, mode)))
79 result = mc_mkdir (s, mode);
81 g_free (q);
82 return result;
85 int
86 my_mkdir (const char *s, mode_t mode)
88 int result;
89 char *my_s;
91 result = mc_mkdir (s, mode);
92 if (result) {
93 char *p = vfs_canon (s);
95 result = my_mkdir_rec (p, mode);
96 g_free (p);
98 if (result == 0) {
99 my_s = get_absolute_name (s);
101 #ifdef FIXME
102 tree_add_entry (tree, my_s);
103 #endif
105 g_free (my_s);
107 return result;
111 my_rmdir (const char *s)
113 int result;
114 char *my_s;
115 #ifdef FIXME
116 WTree *tree = 0;
117 #endif
119 /* FIXME: Should receive a Wtree! */
120 result = mc_rmdir (s);
121 if (result == 0) {
122 my_s = get_absolute_name (s);
124 #ifdef FIXME
125 tree_remove_entry (tree, my_s);
126 #endif
128 g_free (my_s);
130 return result;