l10n: Updates to Korean (ko) translation
[midnight-commander.git] / src / filenot.c
blob2b87932f4ad6ddc2947b30114bed2ac4df467e8b
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 "lib/global.h"
38 #include "lib/fs.h"
40 #include "lib/vfs/mc-vfs/vfs.h"
44 static char *
45 get_absolute_name (const char *file)
47 char dir[MC_MAXPATHLEN];
49 if (file[0] == PATH_SEP)
50 return g_strdup (file);
51 mc_get_current_wd (dir, MC_MAXPATHLEN);
52 return concat_dir_and_file (dir, file);
55 static int
56 my_mkdir_rec (char *s, mode_t mode)
58 char *p, *q;
59 int result;
61 if (!mc_mkdir (s, mode))
62 return 0;
63 else if (errno != ENOENT)
64 return -1;
66 /* FIXME: should check instead if s is at the root of that filesystem */
67 if (!vfs_file_is_local (s))
68 return -1;
70 if (!strcmp (s, PATH_SEP_STR)) {
71 errno = ENOTDIR;
72 return -1;
75 p = concat_dir_and_file (s, "..");
76 q = vfs_canon (p);
77 g_free (p);
79 if (!(result = my_mkdir_rec (q, mode)))
80 result = mc_mkdir (s, mode);
82 g_free (q);
83 return result;
86 int
87 my_mkdir (const char *s, mode_t mode)
89 int result;
90 char *my_s;
92 result = mc_mkdir (s, mode);
93 if (result) {
94 char *p = vfs_canon (s);
96 result = my_mkdir_rec (p, mode);
97 g_free (p);
99 if (result == 0) {
100 my_s = get_absolute_name (s);
102 #ifdef FIXME
103 tree_add_entry (tree, my_s);
104 #endif
106 g_free (my_s);
108 return result;
112 my_rmdir (const char *s)
114 int result;
115 char *my_s;
116 #ifdef FIXME
117 WTree *tree = 0;
118 #endif
120 /* FIXME: Should receive a Wtree! */
121 result = mc_rmdir (s);
122 if (result == 0) {
123 my_s = get_absolute_name (s);
125 #ifdef FIXME
126 tree_remove_entry (tree, my_s);
127 #endif
129 g_free (my_s);
131 return result;