From: teranisi Date: Thu, 3 Jul 2003 11:54:15 +0000 (+0000) Subject: * poe-18.el (make-directory-internal): Signal an error according to X-Git-Tag: apel-10_6~4 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aae52e42df28c1a55d5eefc4965b1bdd27dd9e1;p=elisp%2Fapel.git * poe-18.el (make-directory-internal): Signal an error according to the exit status of mkdir. (delete-directory): New function. (write-region): Ditto. --- diff --git a/ChangeLog b/ChangeLog index 5159d7f..413a06c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-07-03 Yuuichi Teranishi + + * poe-18.el (make-directory-internal): Signal an error according to + the exit status of mkdir. + (delete-directory): New function. + (write-region): Ditto. + 2003-06-06 Yuuichi Teranishi * APEL: Version 10.5 released. diff --git a/poe-18.el b/poe-18.el index 1db66fe..6dd2a90 100644 --- a/poe-18.el +++ b/poe-18.el @@ -668,10 +668,17 @@ For a directory, this means you can access files in that directory." (defun make-directory-internal (dirname) "Create a directory. One argument, a file name string." - (let ((dir (expand-file-name dirname))) - (if (file-exists-p dir) - (error "Creating directory: %s is already exist" dir) - (call-process "mkdir" nil nil nil dir)))) + (let ((dir (expand-file-name dirname))) + (if (file-exists-p dir) + (signal 'file-already-exists + (list "Creating directory: %s already exists" dir)) + (let ((exit-status (call-process "mkdir" nil nil nil dir))) + (if (or (and (numberp exit-status) + (not (zerop exit-status))) + (stringp exit-status)) + (error "Create directory %s failed.") + ;; `make-directory' of v19 and later returns nil for success. + ))))) (defun make-directory (dir &optional parents) "Create the directory DIR and any nonexistent parent dirs. @@ -695,6 +702,13 @@ to create parent directories if they don't exist." (setq p p1))) (make-directory-internal dir))) +(defun delete-directory (directory) + "Delete the directory named DIRECTORY. Does not follow symlinks." + (let ((exit-status (call-process "rmdir" nil nil nil directory))) + (when (or (and (numberp exit-status) (not (zerop exit-status))) + (stringp exit-status)) + (error "Delete directory %s failed.")))) + (defun parse-colon-path (cd-path) "Explode a colon-separated list of paths into a string list." (and cd-path @@ -733,6 +747,38 @@ If MATCH is non-nil, mention only file names that match the regexp MATCH. If NOSORT is dummy for compatibility." (si:directory-files directory full match)) +(or (fboundp 'si:write-region) + (fset 'si:write-region (symbol-function 'write-region))) +(defun write-region (start end filename &optional append visit) + "Write current region into specified file. +When called from a program, requires three arguments: +START, END and FILENAME. START and END are normally buffer positions +specifying the part of the buffer to write. +If START is nil, that means to use the entire buffer contents. +If START is a string, then output that string to the file +instead of any buffer contents; END is ignored. + +Optional fourth argument APPEND if non-nil means + append to existing file contents (if any). If it is an integer, + seek to that offset in the file before writing. +Optional fifth argument VISIT if t means + set the last-save-file-modtime of buffer to this file's modtime + and mark buffer not modified. +If VISIT is a string, it is a second file name; + the output goes to FILENAME, but the buffer is marked as visiting VISIT. + VISIT is also the file name to lock and unlock for clash detection. +If VISIT is neither t nor nil nor a string, + that means do not display the \"Wrote file\" message." + (cond + ((null start) + (si:write-region (point-min) (point-max) filename append visit)) + ((stringp start) + (with-temp-buffer + (insert start) + (si:write-region (point-min) (point-max) filename append visit))) + (t + (si:write-region start end filename append visit)))) + ;;; @ Process. ;;; (or (fboundp 'si:accept-process-output)