2 Wrapper for routines to notify the
3 tree about the changes made to the directory
6 Copyright (C) 2011-2016
7 Free Software Foundation, Inc.
12 Slava Zanko <slavazanko@gmail.com>, 2013
14 This file is part of the Midnight Commander.
16 The Midnight Commander is free software: you can redistribute it
17 and/or modify it under the terms of the GNU General Public License as
18 published by the Free Software Foundation, either version 3 of the License,
19 or (at your option) any later version.
21 The Midnight Commander is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
32 * \brief Source: wrapper for routines to notify the
33 * tree about the changes made to the directory
42 #include "lib/global.h"
45 #include "lib/vfs/vfs.h"
49 /*** global variables ****************************************************************************/
51 /*** file scope macro definitions ****************************************************************/
53 /*** file scope type declarations ****************************************************************/
55 /*** file scope variables ************************************************************************/
57 /*** file scope functions ************************************************************************/
58 /* --------------------------------------------------------------------------------------------- */
61 get_absolute_name (const vfs_path_t
* vpath
)
66 if (IS_PATH_SEP (*vfs_path_get_by_index (vpath
, 0)->path
))
67 return vfs_path_clone (vpath
);
69 return vfs_path_append_vpath_new (vfs_get_raw_current_dir (), vpath
, NULL
);
72 /* --------------------------------------------------------------------------------------------- */
75 my_mkdir_rec (const vfs_path_t
* s_vpath
, mode_t mode
)
80 if (mc_mkdir (s_vpath
, mode
) == 0)
85 /* FIXME: should check instead if s_vpath is at the root of that filesystem */
86 if (!vfs_file_is_local (s_vpath
))
89 if (strcmp (vfs_path_as_str (s_vpath
), PATH_SEP_STR
) == 0)
95 q
= vfs_path_append_new (s_vpath
, "..", (char *) NULL
);
96 result
= my_mkdir_rec (q
, mode
);
100 result
= mc_mkdir (s_vpath
, mode
);
105 /* --------------------------------------------------------------------------------------------- */
106 /*** public functions ****************************************************************************/
107 /* --------------------------------------------------------------------------------------------- */
110 my_mkdir (const vfs_path_t
* s_vpath
, mode_t mode
)
114 result
= my_mkdir_rec (s_vpath
, mode
);
119 my_s
= get_absolute_name (s_vpath
);
120 vfs_path_free (my_s
);
125 /* --------------------------------------------------------------------------------------------- */
128 my_rmdir (const char *s
)
133 vpath
= vfs_path_from_str_flags (s
, VPF_NO_CANON
);
134 /* FIXME: Should receive a Wtree! */
135 result
= mc_rmdir (vpath
);
140 my_s
= get_absolute_name (vpath
);
141 vfs_path_free (my_s
);
143 vfs_path_free (vpath
);
147 /* --------------------------------------------------------------------------------------------- */