X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/2f241ea5576dd3c6ad54b8c14828c8e934fa34a9..404dbd373a91c0b994005e88fe703d9144873b27:/src/dired.c?ds=sidebyside diff --git a/src/dired.c b/src/dired.c index d1b4d41042..48d3da1ead 100644 --- a/src/dired.c +++ b/src/dired.c @@ -1,5 +1,5 @@ /* Lisp functions for making directory listings. - Copyright (C) 1985-1986, 1993-1994, 1999-2011 Free Software Foundation, Inc. + Copyright (C) 1985-1986, 1993-1994, 1999-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -62,6 +62,7 @@ extern struct direct *readdir (DIR *); #endif /* HAVE_DIRENT_H */ #include +#include #ifdef MSDOS #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0) @@ -71,9 +72,9 @@ extern struct direct *readdir (DIR *); #include "lisp.h" #include "systime.h" +#include "character.h" #include "buffer.h" #include "commands.h" -#include "character.h" #include "charset.h" #include "coding.h" #include "regex.h" @@ -87,7 +88,6 @@ static Lisp_Object Qfile_attributes; static Lisp_Object Qfile_attributes_lessp; static ptrdiff_t scmp (const char *, const char *, ptrdiff_t); -static Lisp_Object Ffile_attributes (Lisp_Object, Lisp_Object); #ifdef WINDOWSNT Lisp_Object @@ -229,11 +229,11 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m ptrdiff_t len; int wanted = 0; Lisp_Object name, finalname; - struct gcpro inner_gcpro1, inner_gcpro2; + struct gcpro gcpro1, gcpro2; len = NAMLEN (dp); name = finalname = make_unibyte_string (dp->d_name, len); - GCPRO2_VAR (finalname, name, inner_gcpro); + GCPRO2 (finalname, name); /* Note: DECODE_FILE can GC; it should protect its argument, though. */ @@ -289,23 +289,23 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m /* Construct an expanded filename for the directory entry. Use the decoded names for input to Ffile_attributes. */ Lisp_Object decoded_fullname, fileattrs; - struct gcpro innermost_gcpro1, innermost_gcpro2; + struct gcpro gcpro1, gcpro2; decoded_fullname = fileattrs = Qnil; - GCPRO2_VAR (decoded_fullname, fileattrs, innermost_gcpro); + GCPRO2 (decoded_fullname, fileattrs); /* Both Fexpand_file_name and Ffile_attributes can GC. */ decoded_fullname = Fexpand_file_name (name, directory); fileattrs = Ffile_attributes (decoded_fullname, id_format); list = Fcons (Fcons (finalname, fileattrs), list); - UNGCPRO_VAR (innermost_gcpro); + UNGCPRO; } else list = Fcons (finalname, list); } - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; } } @@ -401,6 +401,7 @@ determined by the variable `completion-ignored-extensions', which see. */) (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate) { Lisp_Object handler; + directory = Fexpand_file_name (directory, Qnil); /* If the directory name has special constructs in it, call the corresponding file handler. */ @@ -424,6 +425,7 @@ These are all file names in directory DIRECTORY which begin with FILE. */) (Lisp_Object file, Lisp_Object directory) { Lisp_Object handler; + directory = Fexpand_file_name (directory, Qnil); /* If the directory name has special constructs in it, call the corresponding file handler. */ @@ -474,7 +476,6 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v bestmatch = Qnil; encoded_file = encoded_dir = Qnil; GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir); - dirname = Fexpand_file_name (dirname, Qnil); specbind (Qdefault_directory, dirname); /* Do completion on the encoded file name @@ -627,7 +628,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v if (includeall && !canexclude) { /* If we have one non-excludable file, we want to exclude the - excudable files. */ + excludable files. */ includeall = 0; /* Throw away any previous excludable match found. */ bestmatch = Qnil; @@ -672,11 +673,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v if (!NILP (predicate)) { Lisp_Object val; - struct gcpro inner_gcpro1; + struct gcpro gcpro1; - GCPRO1_VAR (name, inner_gcpro); + GCPRO1 (name); val = call1 (predicate, name); - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; if (NILP (val)) continue; @@ -892,8 +893,8 @@ Elements of the attribute list are: 2. File uid as a string or a number. If a string value cannot be looked up, a numeric value, either an integer or a float, is returned. 3. File gid, likewise. - 4. Last access time, as a list of two integers. - First integer has high-order 16 bits of time, second has low 16 bits. + 4. Last access time, as a list of integers (HIGH LOW USEC PSEC) in the + same style as (current-time). (See a note below about access time on FAT-based filesystems.) 5. Last modification time, likewise. This is the time of the last change to the file's contents. @@ -978,9 +979,9 @@ so last access time will always be midnight of that day. */) else values[3] = make_fixnum_or_float (s.st_gid); - values[4] = make_time (s.st_atime); - values[5] = make_time (s.st_mtime); - values[6] = make_time (s.st_ctime); + values[4] = make_lisp_time (get_stat_atime (&s)); + values[5] = make_lisp_time (get_stat_mtime (&s)); + values[6] = make_lisp_time (get_stat_ctime (&s)); /* If the file size is a 4-byte type, assume that files of sizes in the 2-4 GiB range wrap around to negative values, as this is a @@ -1017,6 +1018,45 @@ Comparison is in lexicographic order and case is significant. */) return Fstring_lessp (Fcar (f1), Fcar (f2)); } + +DEFUN ("system-users", Fsystem_users, Ssystem_users, 0, 0, 0, + doc: /* Return a list of user names currently registered in the system. +If we don't know how to determine that on this platform, just +return a list with one element, taken from `user-real-login-name'. */) + (void) +{ + Lisp_Object users = Qnil; +#if defined HAVE_GETPWENT && defined HAVE_ENDPWENT + struct passwd *pw; + + while ((pw = getpwent ())) + users = Fcons (DECODE_SYSTEM (build_string (pw->pw_name)), users); + + endpwent (); +#endif + if (EQ (users, Qnil)) + /* At least current user is always known. */ + users = Fcons (Vuser_real_login_name, Qnil); + return users; +} + +DEFUN ("system-groups", Fsystem_groups, Ssystem_groups, 0, 0, 0, + doc: /* Return a list of user group names currently registered in the system. +The value may be nil if not supported on this platform. */) + (void) +{ + Lisp_Object groups = Qnil; +#if defined HAVE_GETGRENT && defined HAVE_ENDGRENT + struct group *gr; + + while ((gr = getgrent ())) + groups = Fcons (DECODE_SYSTEM (build_string (gr->gr_name)), groups); + + endgrent (); +#endif + return groups; +} + void syms_of_dired (void) { @@ -1034,6 +1074,8 @@ syms_of_dired (void) defsubr (&Sfile_name_all_completions); defsubr (&Sfile_attributes); defsubr (&Sfile_attributes_lessp); + defsubr (&Ssystem_users); + defsubr (&Ssystem_groups); DEFVAR_LISP ("completion-ignored-extensions", Vcompletion_ignored_extensions, doc: /* Completion ignores file names ending in any string in this list.