2 Wrapper for routines to notify the
3 tree about the changes made to the directory
7 The Free Software Foundation, Inc.
13 This file is part of the Midnight Commander.
15 The Midnight Commander is free software: you can redistribute it
16 and/or modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation, either version 3 of the License,
18 or (at your option) any later version.
20 The Midnight Commander is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 * \brief Source: wrapper for routines to notify the
32 * tree about the changes made to the directory
41 #include "lib/global.h"
44 #include "lib/vfs/vfs.h"
46 /*** global variables ****************************************************************************/
48 /*** file scope macro definitions ****************************************************************/
50 /*** file scope type declarations ****************************************************************/
52 /*** file scope variables ************************************************************************/
54 /*** file scope functions ************************************************************************/
55 /* --------------------------------------------------------------------------------------------- */
58 get_absolute_name (const char *file
)
60 char dir
[MC_MAXPATHLEN
];
62 if (file
[0] == PATH_SEP
)
63 return g_strdup (file
);
64 mc_get_current_wd (dir
, MC_MAXPATHLEN
);
65 return concat_dir_and_file (dir
, file
);
68 /* --------------------------------------------------------------------------------------------- */
71 my_mkdir_rec (char *s
, mode_t mode
)
77 s_vpath
= vfs_path_from_str (s
);
78 if (mc_mkdir (s_vpath
, mode
) == 0)
80 vfs_path_free (s_vpath
);
83 else if (errno
!= ENOENT
)
85 vfs_path_free (s_vpath
);
89 /* FIXME: should check instead if s is at the root of that filesystem */
91 if (!vfs_file_is_local (s_vpath
))
93 vfs_path_free (s_vpath
);
98 if (!strcmp (s
, PATH_SEP_STR
))
101 vfs_path_free (s_vpath
);
105 p
= concat_dir_and_file (s
, "..");
109 vpath
= vfs_path_from_str (p
);
110 q
= vfs_path_to_str (vpath
);
111 vfs_path_free (vpath
);
115 result
= my_mkdir_rec (q
, mode
);
117 result
= mc_mkdir (s_vpath
, mode
);
119 vfs_path_free (s_vpath
);
124 /* --------------------------------------------------------------------------------------------- */
125 /*** public functions ****************************************************************************/
126 /* --------------------------------------------------------------------------------------------- */
129 my_mkdir (const char *s
, mode_t mode
)
135 s_vpath
= vfs_path_from_str (s
);
136 result
= mc_mkdir (s_vpath
, mode
);
142 p
= vfs_path_to_str (s_vpath
);
143 result
= my_mkdir_rec (p
, mode
);
148 my_s
= get_absolute_name (s
);
151 tree_add_entry (tree
, my_s
);
156 vfs_path_free (s_vpath
);
160 /* --------------------------------------------------------------------------------------------- */
163 my_rmdir (const char *s
)
172 vpath
= vfs_path_from_str (s
);
173 /* FIXME: Should receive a Wtree! */
174 result
= mc_rmdir (vpath
);
177 my_s
= get_absolute_name (s
);
180 tree_remove_entry (tree
, my_s
);
185 vfs_path_free (vpath
);
189 /* --------------------------------------------------------------------------------------------- */