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
)
76 if (!mc_mkdir (s
, mode
))
78 else if (errno
!= ENOENT
)
81 /* FIXME: should check instead if s is at the root of that filesystem */
83 vfs_path_t
*vpath
= vfs_path_from_str (s
);
84 if (!vfs_file_is_local (vpath
))
86 vfs_path_free (vpath
);
89 vfs_path_free (vpath
);
92 if (!strcmp (s
, PATH_SEP_STR
))
98 p
= concat_dir_and_file (s
, "..");
100 vfs_path_t
*vpath
= vfs_path_from_str (p
);
101 q
= vfs_path_to_str (vpath
);
102 vfs_path_free (vpath
);
106 result
= my_mkdir_rec (q
, mode
);
108 result
= mc_mkdir (s
, mode
);
114 /* --------------------------------------------------------------------------------------------- */
115 /*** public functions ****************************************************************************/
116 /* --------------------------------------------------------------------------------------------- */
119 my_mkdir (const char *s
, mode_t mode
)
124 result
= mc_mkdir (s
, mode
);
129 vpath
= vfs_path_from_str (s
);
130 p
= vfs_path_to_str (vpath
);
132 result
= my_mkdir_rec (p
, mode
);
133 vfs_path_free (vpath
);
138 my_s
= get_absolute_name (s
);
141 tree_add_entry (tree
, my_s
);
149 /* --------------------------------------------------------------------------------------------- */
152 my_rmdir (const char *s
)
160 /* FIXME: Should receive a Wtree! */
161 result
= mc_rmdir (s
);
164 my_s
= get_absolute_name (s
);
167 tree_remove_entry (tree
, my_s
);
175 /* --------------------------------------------------------------------------------------------- */