2 filenot.c: wrapper for routines to notify the
3 tree about the changes made to the directory
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.
27 * \brief Source: wrapper for routines to notify the
28 * tree about the changes made to the directory
37 #include "lib/global.h"
40 #include "lib/vfs/mc-vfs/vfs.h"
42 /*** global variables ****************************************************************************/
44 /*** file scope macro definitions ****************************************************************/
46 /*** file scope type declarations ****************************************************************/
48 /*** file scope variables ************************************************************************/
50 /*** file scope functions ************************************************************************/
51 /* --------------------------------------------------------------------------------------------- */
54 get_absolute_name (const char *file
)
56 char dir
[MC_MAXPATHLEN
];
58 if (file
[0] == PATH_SEP
)
59 return g_strdup (file
);
60 mc_get_current_wd (dir
, MC_MAXPATHLEN
);
61 return concat_dir_and_file (dir
, file
);
64 /* --------------------------------------------------------------------------------------------- */
67 my_mkdir_rec (char *s
, mode_t mode
)
72 if (!mc_mkdir (s
, mode
))
74 else if (errno
!= ENOENT
)
77 /* FIXME: should check instead if s is at the root of that filesystem */
78 if (!vfs_file_is_local (s
))
81 if (!strcmp (s
, PATH_SEP_STR
))
87 p
= concat_dir_and_file (s
, "..");
91 result
= my_mkdir_rec (q
, mode
);
93 result
= mc_mkdir (s
, mode
);
99 /* --------------------------------------------------------------------------------------------- */
100 /*** public functions ****************************************************************************/
101 /* --------------------------------------------------------------------------------------------- */
104 my_mkdir (const char *s
, mode_t mode
)
109 result
= mc_mkdir (s
, mode
);
112 char *p
= vfs_canon (s
);
114 result
= my_mkdir_rec (p
, mode
);
119 my_s
= get_absolute_name (s
);
122 tree_add_entry (tree
, my_s
);
130 /* --------------------------------------------------------------------------------------------- */
133 my_rmdir (const char *s
)
141 /* FIXME: Should receive a Wtree! */
142 result
= mc_rmdir (s
);
145 my_s
= get_absolute_name (s
);
148 tree_remove_entry (tree
, my_s
);
156 /* --------------------------------------------------------------------------------------------- */