Mercurial > emacs
comparison src/fileio.c @ 109206:922942081399
Merge from mainline.
author | Katsumi Yamaoka <katsumi@flagship2> |
---|---|
date | Fri, 28 May 2010 11:27:13 +0000 |
parents | 511da81b16c5 |
children | 6515310887ec |
comparison
equal
deleted
inserted
replaced
109205:f6714012e3cb | 109206:922942081399 |
---|---|
2178 Lisp_Object handler; | 2178 Lisp_Object handler; |
2179 Lisp_Object encoded_dir; | 2179 Lisp_Object encoded_dir; |
2180 | 2180 |
2181 CHECK_STRING (directory); | 2181 CHECK_STRING (directory); |
2182 directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); | 2182 directory = Fdirectory_file_name (Fexpand_file_name (directory, Qnil)); |
2183 | |
2184 if (delete_by_moving_to_trash) | |
2185 return call1 (Qmove_file_to_trash, directory); | |
2186 | |
2187 encoded_dir = ENCODE_FILE (directory); | 2183 encoded_dir = ENCODE_FILE (directory); |
2188 | |
2189 dir = SDATA (encoded_dir); | 2184 dir = SDATA (encoded_dir); |
2190 | 2185 |
2191 if (rmdir (dir) != 0) | 2186 if (rmdir (dir) != 0) |
2192 report_file_error ("Removing directory", list1 (directory)); | 2187 report_file_error ("Removing directory", list1 (directory)); |
2193 | 2188 |
2194 return Qnil; | 2189 return Qnil; |
2195 } | 2190 } |
2196 | 2191 |
2197 DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, | 2192 DEFUN ("delete-file", Fdelete_file, Sdelete_file, 1, 2, |
2198 "(list (read-file-name \"Delete file: \" nil default-directory \ | 2193 "(list (read-file-name \ |
2199 (confirm-nonexistent-file-or-buffer)) \ | 2194 (if (and delete-by-moving-to-trash (null current-prefix-arg)) \ |
2200 current-prefix-arg)", | 2195 \"Move file to trash: \" \"Delete file: \") \ |
2196 nil default-directory (confirm-nonexistent-file-or-buffer)) \ | |
2197 (null current-prefix-arg))", | |
2201 doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. | 2198 doc: /* Delete file named FILENAME. If it is a symlink, remove the symlink. |
2202 If file has multiple names, it continues to exist with the other names. | 2199 If file has multiple names, it continues to exist with the other names. |
2203 | 2200 TRASH non-nil means to trash the file instead of deleting, provided |
2204 If optional arg FORCE is non-nil, really delete the file regardless of | 2201 `delete-by-moving-to-trash' is non-nil. |
2205 `delete-by-moving-to-trash'. Otherwise, \"deleting\" actually moves | 2202 |
2206 it to the system's trash can if `delete-by-moving-to-trash' is non-nil. | 2203 When called interactively, TRASH is t if no prefix argument is given. |
2207 Interactively, FORCE is non-nil if called with a prefix arg. */) | 2204 With a prefix argument, TRASH is nil. */) |
2208 (filename, force) | 2205 (filename, trash) |
2209 Lisp_Object filename; | 2206 Lisp_Object filename; |
2210 Lisp_Object force; | 2207 Lisp_Object trash; |
2211 { | 2208 { |
2212 Lisp_Object handler; | 2209 Lisp_Object handler; |
2213 Lisp_Object encoded_file; | 2210 Lisp_Object encoded_file; |
2214 struct gcpro gcpro1; | 2211 struct gcpro gcpro1; |
2215 | 2212 |
2224 | 2221 |
2225 handler = Ffind_file_name_handler (filename, Qdelete_file); | 2222 handler = Ffind_file_name_handler (filename, Qdelete_file); |
2226 if (!NILP (handler)) | 2223 if (!NILP (handler)) |
2227 return call2 (handler, Qdelete_file, filename); | 2224 return call2 (handler, Qdelete_file, filename); |
2228 | 2225 |
2229 if (delete_by_moving_to_trash && NILP (force)) | 2226 if (delete_by_moving_to_trash && !NILP (trash)) |
2230 return call1 (Qmove_file_to_trash, filename); | 2227 return call1 (Qmove_file_to_trash, filename); |
2231 | 2228 |
2232 encoded_file = ENCODE_FILE (filename); | 2229 encoded_file = ENCODE_FILE (filename); |
2233 | 2230 |
2234 if (0 > unlink (SDATA (encoded_file))) | 2231 if (0 > unlink (SDATA (encoded_file))) |
2242 { | 2239 { |
2243 return Qt; | 2240 return Qt; |
2244 } | 2241 } |
2245 | 2242 |
2246 /* Delete file FILENAME, returning 1 if successful and 0 if failed. | 2243 /* Delete file FILENAME, returning 1 if successful and 0 if failed. |
2247 FORCE means to ignore `delete-by-moving-to-trash'. */ | 2244 This ignores `delete-by-moving-to-trash'. */ |
2248 | 2245 |
2249 int | 2246 int |
2250 internal_delete_file (Lisp_Object filename, Lisp_Object force) | 2247 internal_delete_file (Lisp_Object filename) |
2251 { | 2248 { |
2252 Lisp_Object tem; | 2249 Lisp_Object tem; |
2253 | 2250 |
2254 tem = internal_condition_case_2 (Fdelete_file, filename, force, | 2251 tem = internal_condition_case_2 (Fdelete_file, filename, Qnil, |
2255 Qt, internal_delete_file_1); | 2252 Qt, internal_delete_file_1); |
2256 return NILP (tem); | 2253 return NILP (tem); |
2257 } | 2254 } |
2258 | 2255 |
2259 DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, | 2256 DEFUN ("rename-file", Frename_file, Srename_file, 2, 3, |
2343 && NILP (symlink_target) | 2340 && NILP (symlink_target) |
2344 #endif | 2341 #endif |
2345 ) | 2342 ) |
2346 call2 (Qdelete_directory, file, Qt); | 2343 call2 (Qdelete_directory, file, Qt); |
2347 else | 2344 else |
2348 Fdelete_file (file, Qt); | 2345 Fdelete_file (file, Qnil); |
2349 unbind_to (count, Qnil); | 2346 unbind_to (count, Qnil); |
2350 } | 2347 } |
2351 else | 2348 else |
2352 report_file_error ("Renaming", list2 (file, newname)); | 2349 report_file_error ("Renaming", list2 (file, newname)); |
2353 } | 2350 } |
5915 write_region_inhibit_fsync = 0; | 5912 write_region_inhibit_fsync = 0; |
5916 #endif | 5913 #endif |
5917 | 5914 |
5918 DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, | 5915 DEFVAR_BOOL ("delete-by-moving-to-trash", &delete_by_moving_to_trash, |
5919 doc: /* Specifies whether to use the system's trash can. | 5916 doc: /* Specifies whether to use the system's trash can. |
5920 When non-nil, the function `move-file-to-trash' will be used by | 5917 When non-nil, certain file deletion commands use the function |
5921 `delete-file' and `delete-directory'. */); | 5918 `move-file-to-trash' instead of deleting files outright. |
5919 This includes interactive calls to `delete-file' and | |
5920 `delete-directory' and the Dired deletion commands. */); | |
5922 delete_by_moving_to_trash = 0; | 5921 delete_by_moving_to_trash = 0; |
5923 Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); | 5922 Qdelete_by_moving_to_trash = intern_c_string ("delete-by-moving-to-trash"); |
5924 Qmove_file_to_trash = intern_c_string ("move-file-to-trash"); | 5923 Qmove_file_to_trash = intern_c_string ("move-file-to-trash"); |
5925 staticpro (&Qmove_file_to_trash); | 5924 staticpro (&Qmove_file_to_trash); |
5926 Qcopy_directory = intern_c_string ("copy-directory"); | 5925 Qcopy_directory = intern_c_string ("copy-directory"); |