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"
48 /*** global variables ****************************************************************************/
50 /*** file scope macro definitions ****************************************************************/
52 /*** file scope type declarations ****************************************************************/
54 /*** file scope variables ************************************************************************/
56 /*** file scope functions ************************************************************************/
57 /* --------------------------------------------------------------------------------------------- */
60 get_absolute_name (const vfs_path_t
* vpath
)
65 if (*(vfs_path_get_by_index (vpath
, 0)->path
) == PATH_SEP
)
66 return vfs_path_clone (vpath
);
68 return vfs_path_append_vpath_new (vfs_get_raw_current_dir (), vpath
);
71 /* --------------------------------------------------------------------------------------------- */
74 my_mkdir_rec (char *s
, mode_t mode
)
80 s_vpath
= vfs_path_from_str (s
);
81 if (mc_mkdir (s_vpath
, mode
) == 0)
83 vfs_path_free (s_vpath
);
86 else if (errno
!= ENOENT
)
88 vfs_path_free (s_vpath
);
92 /* FIXME: should check instead if s is at the root of that filesystem */
94 if (!vfs_file_is_local (s_vpath
))
96 vfs_path_free (s_vpath
);
101 if (!strcmp (s
, PATH_SEP_STR
))
104 vfs_path_free (s_vpath
);
108 p
= mc_build_filename (s
, "..", NULL
);
112 vpath
= vfs_path_from_str (p
);
113 q
= vfs_path_to_str (vpath
);
114 vfs_path_free (vpath
);
118 result
= my_mkdir_rec (q
, mode
);
120 result
= mc_mkdir (s_vpath
, mode
);
122 vfs_path_free (s_vpath
);
127 /* --------------------------------------------------------------------------------------------- */
128 /*** public functions ****************************************************************************/
129 /* --------------------------------------------------------------------------------------------- */
132 my_mkdir (const vfs_path_t
* s_vpath
, mode_t mode
)
136 result
= mc_mkdir (s_vpath
, mode
);
142 p
= vfs_path_to_str (s_vpath
);
143 result
= my_mkdir_rec (p
, mode
);
150 my_s
= get_absolute_name (s_vpath
);
152 tree_add_entry (tree
, my_s
);
154 vfs_path_free (my_s
);
159 /* --------------------------------------------------------------------------------------------- */
162 my_rmdir (const char *s
)
170 vpath
= vfs_path_from_str_flags (s
, VPF_NO_CANON
);
171 /* FIXME: Should receive a Wtree! */
172 result
= mc_rmdir (vpath
);
177 my_s
= get_absolute_name (vpath
);
179 tree_remove_entry (tree
, my_s
);
181 vfs_path_free (my_s
);
183 vfs_path_free (vpath
);
187 /* --------------------------------------------------------------------------------------------- */