Mercurial > octave-nkf
comparison liboctave/file-ops.cc @ 1773:5215571ea783
[project @ 1996-01-23 08:10:26 by jwe]
author | jwe |
---|---|
date | Tue, 23 Jan 1996 08:11:08 +0000 |
parents | 95c4c5705909 |
children | d53c27b14236 |
comparison
equal
deleted
inserted
replaced
1772:95c4c5705909 | 1773:5215571ea783 |
---|---|
32 #include <sys/types.h> | 32 #include <sys/types.h> |
33 #include <unistd.h> | 33 #include <unistd.h> |
34 #endif | 34 #endif |
35 | 35 |
36 #include "file-ops.h" | 36 #include "file-ops.h" |
37 #include "safe-lstat.h" | |
38 #include "safe-stat.h" | |
37 #include "statdefs.h" | 39 #include "statdefs.h" |
38 | 40 |
39 // XXX FIXME XXX -- the is_* and mode_as_string functions are only valid | 41 // XXX FIXME XXX -- the is_* and mode_as_string functions are only valid |
40 // for initialized objects. If called for an object that is not | 42 // for initialized objects. If called for an object that is not |
41 // initialized, they should throw an exception. | 43 // initialized, they should throw an exception. |
109 const char *cname = file_name.c_str (); | 111 const char *cname = file_name.c_str (); |
110 | 112 |
111 struct stat buf; | 113 struct stat buf; |
112 | 114 |
113 int status = follow_links | 115 int status = follow_links |
114 ? stat (cname, &buf) : lstat (cname, &buf); | 116 ? safe_stat (cname, &buf) : safe_lstat (cname, &buf); |
115 | 117 |
116 if (status < 0) | 118 if (status < 0) |
117 { | 119 { |
118 fail = true; | 120 fail = true; |
119 errmsg = strerror (errno); | 121 errmsg = strerror (errno); |
165 { | 167 { |
166 return mkdir (name.c_str (), mode); | 168 return mkdir (name.c_str (), mode); |
167 } | 169 } |
168 | 170 |
169 int | 171 int |
172 oct_mkfifo (const string& name, mode_t mode) | |
173 { | |
174 return mkfifo (name.c_str (), mode); | |
175 } | |
176 | |
177 int | |
178 oct_rename (const string& from, const string& to) | |
179 { | |
180 return rename (from.c_str (), to.c_str ()); | |
181 } | |
182 | |
183 int | |
170 oct_rmdir (const string& name) | 184 oct_rmdir (const string& name) |
171 { | 185 { |
172 return rmdir (name.c_str ()); | 186 return rmdir (name.c_str ()); |
173 } | |
174 | |
175 int | |
176 oct_rename (const string& from, const string& to) | |
177 { | |
178 return rename (from.c_str (), to.c_str ()); | |
179 } | |
180 | |
181 int | |
182 oct_mkfifo (const string& name, mode_t mode) | |
183 { | |
184 return mkfifo (name.c_str (), mode); | |
185 } | 187 } |
186 | 188 |
187 int | 189 int |
188 oct_umask (mode_t mode) | 190 oct_umask (mode_t mode) |
189 { | 191 { |
190 #if defined (HAVE_UMASK) | 192 #if defined (HAVE_UMASK) |
191 return umask (mode); | 193 return umask (mode); |
192 #else | 194 #else |
193 return 0; | 195 return 0; |
194 #endif | 196 #endif |
197 } | |
198 | |
199 int | |
200 oct_unlink (const string& name) | |
201 { | |
202 return unlink (name.c_str ()); | |
195 } | 203 } |
196 | 204 |
197 /* | 205 /* |
198 ;;; Local Variables: *** | 206 ;;; Local Variables: *** |
199 ;;; mode: C++ *** | 207 ;;; mode: C++ *** |