fix panel_scroll_pages start page
[midnight-commander.git] / src / filenot.c
blob75f8b20ee28fb6ac531c27b9c3945ec41e56b38d
1 /*
2 filenot.c: wrapper for routines to notify the
3 tree about the changes made to the directory
4 structure.
6 Author:
7 Janne Kukonlehto
8 Miguel de Icaza
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include <config.h>
26 #include <string.h>
27 #include <errno.h>
28 #include "global.h"
29 #include "../vfs/vfs.h"
31 static char *get_absolute_name (char *file)
33 char dir [MC_MAXPATHLEN];
35 if (file [0] == PATH_SEP)
36 return g_strdup (file);
37 mc_get_current_wd (dir, MC_MAXPATHLEN);
38 return concat_dir_and_file (dir, file);
41 static int
42 my_mkdir_rec (char *s, mode_t mode)
44 char *p, *q;
45 int result;
47 if (!mc_mkdir (s, mode))
48 return 0;
49 else if (errno != ENOENT)
50 return -1;
52 /* FIXME: should check instead if s is at the root of that filesystem */
53 if (!vfs_file_is_local (s))
54 return -1;
56 if (!strcmp (s, PATH_SEP_STR)) {
57 errno = ENOTDIR;
58 return -1;
61 p = concat_dir_and_file (s, "..");
62 q = vfs_canon (p);
63 g_free (p);
65 if (!(result = my_mkdir_rec (q, mode)))
66 result = mc_mkdir (s, mode);
68 g_free (q);
69 return result;
72 int
73 my_mkdir (char *s, mode_t mode)
75 int result;
77 result = mc_mkdir (s, mode);
78 #ifdef NATIVE_WIN32
79 /* .ado: it will be disabled in Win32 */
80 /* otherwise crash if directory already exists. */
81 return result;
82 #endif
83 if (result) {
84 char *p = vfs_canon (s);
86 result = my_mkdir_rec (p, mode);
87 g_free (p);
89 if (result == 0){
90 s = get_absolute_name (s);
92 #if FIXME
93 tree_add_entry (tree, s);
94 #endif
96 g_free (s);
98 return result;
101 int my_rmdir (char *s)
103 int result;
104 #if FIXME
105 WTree *tree = 0;
106 #endif
108 /* FIXME: Should receive a Wtree! */
109 result = mc_rmdir (s);
110 if (result == 0){
111 s = get_absolute_name (s);
113 #if FIXME
114 tree_remove_entry (tree, s);
115 #endif
117 g_free (s);
119 return result;