updated the .TP cleanup for coherency in the key description pages.
[midnight-commander.git] / src / filenot.c
blobe7aec4b0cc51e07ed647256361d74169c854c81a
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <config.h>
26 #include <string.h>
27 #include <errno.h>
28 #include "global.h"
29 #include "../vfs/vfs.h"
31 static char *
32 get_absolute_name (char *file)
34 char dir[MC_MAXPATHLEN];
36 if (file[0] == PATH_SEP)
37 return g_strdup (file);
38 mc_get_current_wd (dir, MC_MAXPATHLEN);
39 return concat_dir_and_file (dir, file);
42 static int
43 my_mkdir_rec (char *s, mode_t mode)
45 char *p, *q;
46 int result;
48 if (!mc_mkdir (s, mode))
49 return 0;
50 else if (errno != ENOENT)
51 return -1;
53 /* FIXME: should check instead if s is at the root of that filesystem */
54 if (!vfs_file_is_local (s))
55 return -1;
57 if (!strcmp (s, PATH_SEP_STR)) {
58 errno = ENOTDIR;
59 return -1;
62 p = concat_dir_and_file (s, "..");
63 q = vfs_canon (p);
64 g_free (p);
66 if (!(result = my_mkdir_rec (q, mode)))
67 result = mc_mkdir (s, mode);
69 g_free (q);
70 return result;
73 int
74 my_mkdir (char *s, mode_t mode)
76 int result;
78 result = mc_mkdir (s, mode);
79 #ifdef NATIVE_WIN32
80 /* .ado: it will be disabled in Win32 */
81 /* otherwise crash if directory already exists. */
82 return result;
83 #endif
84 if (result) {
85 char *p = vfs_canon (s);
87 result = my_mkdir_rec (p, mode);
88 g_free (p);
90 if (result == 0) {
91 s = get_absolute_name (s);
93 #if FIXME
94 tree_add_entry (tree, s);
95 #endif
97 g_free (s);
99 return result;
103 my_rmdir (char *s)
105 int result;
106 #if FIXME
107 WTree *tree = 0;
108 #endif
110 /* FIXME: Should receive a Wtree! */
111 result = mc_rmdir (s);
112 if (result == 0) {
113 s = get_absolute_name (s);
115 #if FIXME
116 tree_remove_entry (tree, s);
117 #endif
119 g_free (s);
121 return result;