aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-05 09:33:33 +0000
committerRichard M. Stallman1994-10-05 09:33:33 +0000
commitf793dc6c1e7dfb38798149d609e7b6eaba65585f (patch)
treea53e840922dd50bae590453ac8b1833e006fed80 /src
parent8b740009092af7eeb3950f98f0b515ce47c60e60 (diff)
downloademacs-f793dc6c1e7dfb38798149d609e7b6eaba65585f.tar.gz
emacs-f793dc6c1e7dfb38798149d609e7b6eaba65585f.zip
(Ffile_regular_p): New function.
(syms_of_fileio): defsubr it.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c98
1 files changed, 61 insertions, 37 deletions
diff --git a/src/fileio.c b/src/fileio.c
index d72aabcb423..6756bf55294 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2274,6 +2274,42 @@ See also `file-exists-p' and `file-attributes'.")
2274 return Qt; 2274 return Qt;
2275} 2275}
2276 2276
2277/* Having this before file-symlink-p mysteriously caused it to be forgotten
2278 on the RT/PC. */
2279DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
2280 "Return t if file FILENAME can be written or created by you.")
2281 (filename)
2282 Lisp_Object filename;
2283{
2284 Lisp_Object abspath, dir;
2285 Lisp_Object handler;
2286 struct stat statbuf;
2287
2288 CHECK_STRING (filename, 0);
2289 abspath = Fexpand_file_name (filename, Qnil);
2290
2291 /* If the file name has special constructs in it,
2292 call the corresponding file handler. */
2293 handler = Ffind_file_name_handler (abspath, Qfile_writable_p);
2294 if (!NILP (handler))
2295 return call2 (handler, Qfile_writable_p, abspath);
2296
2297 if (stat (XSTRING (abspath)->data, &statbuf) >= 0)
2298 return (check_writable (XSTRING (abspath)->data)
2299 ? Qt : Qnil);
2300 dir = Ffile_name_directory (abspath);
2301#ifdef VMS
2302 if (!NILP (dir))
2303 dir = Fdirectory_file_name (dir);
2304#endif /* VMS */
2305#ifdef MSDOS
2306 if (!NILP (dir))
2307 dir = Fdirectory_file_name (dir);
2308#endif /* MSDOS */
2309 return (check_writable (!NILP (dir) ? (char *) XSTRING (dir)->data : "")
2310 ? Qt : Qnil);
2311}
2312
2277DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0, 2313DEFUN ("file-symlink-p", Ffile_symlink_p, Sfile_symlink_p, 1, 1, 0,
2278 "Return non-nil if file FILENAME is the name of a symbolic link.\n\ 2314 "Return non-nil if file FILENAME is the name of a symbolic link.\n\
2279The value is the name of the file to which it is linked.\n\ 2315The value is the name of the file to which it is linked.\n\
@@ -2321,42 +2357,6 @@ Otherwise returns nil.")
2321#endif /* not S_IFLNK */ 2357#endif /* not S_IFLNK */
2322} 2358}
2323 2359
2324/* Having this before file-symlink-p mysteriously caused it to be forgotten
2325 on the RT/PC. */
2326DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
2327 "Return t if file FILENAME can be written or created by you.")
2328 (filename)
2329 Lisp_Object filename;
2330{
2331 Lisp_Object abspath, dir;
2332 Lisp_Object handler;
2333 struct stat statbuf;
2334
2335 CHECK_STRING (filename, 0);
2336 abspath = Fexpand_file_name (filename, Qnil);
2337
2338 /* If the file name has special constructs in it,
2339 call the corresponding file handler. */
2340 handler = Ffind_file_name_handler (abspath, Qfile_writable_p);
2341 if (!NILP (handler))
2342 return call2 (handler, Qfile_writable_p, abspath);
2343
2344 if (stat (XSTRING (abspath)->data, &statbuf) >= 0)
2345 return (check_writable (XSTRING (abspath)->data)
2346 ? Qt : Qnil);
2347 dir = Ffile_name_directory (abspath);
2348#ifdef VMS
2349 if (!NILP (dir))
2350 dir = Fdirectory_file_name (dir);
2351#endif /* VMS */
2352#ifdef MSDOS
2353 if (!NILP (dir))
2354 dir = Fdirectory_file_name (dir);
2355#endif /* MSDOS */
2356 return (check_writable (!NILP (dir) ? (char *) XSTRING (dir)->data : "")
2357 ? Qt : Qnil);
2358}
2359
2360DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, 2360DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,
2361 "Return t if file FILENAME is the name of a directory as a file.\n\ 2361 "Return t if file FILENAME is the name of a directory as a file.\n\
2362A directory name spec may be given instead; then the value is t\n\ 2362A directory name spec may be given instead; then the value is t\n\
@@ -2414,6 +2414,29 @@ searchable directory.")
2414 return tem ? Qnil : Qt; 2414 return tem ? Qnil : Qt;
2415} 2415}
2416 2416
2417DEFUN ("file-regular-p", Ffile_regular_p, Sfile_regular_p, 1, 1, 0,
2418 "Return t if file FILENAME is the name of a regular file.\n\
2419This is the sort of file that holds an ordinary stream of data bytes.")
2420 (filename)
2421 Lisp_Object filename;
2422{
2423 register Lisp_Object abspath;
2424 struct stat st;
2425 Lisp_Object handler;
2426
2427 abspath = expand_and_dir_to_file (filename, current_buffer->directory);
2428
2429 /* If the file name has special constructs in it,
2430 call the corresponding file handler. */
2431 handler = Ffind_file_name_handler (abspath, Qfile_directory_p);
2432 if (!NILP (handler))
2433 return call2 (handler, Qfile_directory_p, abspath);
2434
2435 if (stat (XSTRING (abspath)->data, &st) < 0)
2436 return Qnil;
2437 return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil;
2438}
2439
2417DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0, 2440DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0,
2418 "Return mode bits of FILE, as an integer.") 2441 "Return mode bits of FILE, as an integer.")
2419 (filename) 2442 (filename)
@@ -2529,7 +2552,7 @@ The value is an integer.")
2529 XSETINT (value, (~ realmask) & 0777); 2552 XSETINT (value, (~ realmask) & 0777);
2530 return value; 2553 return value;
2531} 2554}
2532 2555
2533#ifdef unix 2556#ifdef unix
2534 2557
2535DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "", 2558DEFUN ("unix-sync", Funix_sync, Sunix_sync, 0, 0, "",
@@ -4210,6 +4233,7 @@ This applies only to the operation `inhibit-file-name-operation'.");
4210 defsubr (&Sfile_symlink_p); 4233 defsubr (&Sfile_symlink_p);
4211 defsubr (&Sfile_directory_p); 4234 defsubr (&Sfile_directory_p);
4212 defsubr (&Sfile_accessible_directory_p); 4235 defsubr (&Sfile_accessible_directory_p);
4236 defsubr (&Sfile_regular_p);
4213 defsubr (&Sfile_modes); 4237 defsubr (&Sfile_modes);
4214 defsubr (&Sset_file_modes); 4238 defsubr (&Sset_file_modes);
4215 defsubr (&Sset_default_file_modes); 4239 defsubr (&Sset_default_file_modes);