[Mew-Win32 03257] Re: 日本語ファイル名のファイルの添付

Hideyuki SHIRAI ( 白井秀行 ) shirai at example.com
2001年 5月 28日 (月) 20:28:53 JST


From: Shun-ichi GOTO <gotoh at example.com> さん曰く
Subject: [Mew-Win32 03256] Re: 日本語ファイル名のファイルの添付
Message-ID: <20010528.192953.80269987.gotoh at example.com>
Date: Mon, 28 May 2001 19:29:53 +0900 (JST)

白井> 事故回答^H^H^H^H自己解凍な zip ってどうやって作るのかわからなかっ
白井> たんですが、

後> on UNIX:  cat unzipsfx foo.zip >foo
後>           zip -A foo

後> on Win32: copy /b unzipsfx.exe+foo.zip foo.exe
後> 	  zip -A foo.exe

あ、こうやればよかったんですね。その部分は一回読んだんだけどな ^^;;;
なんとまぁ、MS で作った unzipsfx.exe を Solaris に copy して

on Solaris7:  cat unzipsfx.exe foo.zip > foo.exe
              zip -A foo.exe

で foo.exe を作ると Windows で自己解凍出来てしまいました。
こういうやるのは Win な人相手だから、これって、すっごく幸せな挙
動ですな。Solaris な ELF つけても誰もダメだろうし。

## 最初、(insert mew-attach-unzipsfx-prog) って書いて全然動かな
## いで悩んだのは内緒かも。で、ごちゃごちゃやっているうちに
## default-directory とか移動した残骸が残っています。

(defvar mew-attach-unzipsfx-prog
  (if (featurep 'meadow)
      "c:/usr/local/etc/unzipsfx.exe"
    "/usr/local/etc/unzipsfx.exe"))

(defun mew-attach-copy-with-zip (&optional sfx)
  "file/directory を zip して attach する。
C-u 付きだと Windows 向け自己解凍 file を作る。"  
  (interactive "P")
  (let (frompath compfile dir args)
    (while (or (null frompath)
	       (and (file-directory-p (file-chase-links frompath))
		    (not (y-or-n-p (format "\"%s\" is directory. OK ? "
					   frompath)))))
      (setq frompath (mew-draft-input-file-name "Copy with ZIP from: ")))
    (when (and sfx
	       (not (y-or-n-p "Make self extract file for Windows ? ")))
      (setq sfx nil))
    (setq compfile
	  (expand-file-name
	   (concat (file-name-nondirectory
		    (directory-file-name
		     (file-name-as-directory frompath)))
		   (if sfx ".exe" ".zip"))
	   mew-temp-dir))
    (if (file-directory-p (file-chase-links frompath))
	(progn
	  (setq args "-9qr")
	  (setq frompath (file-name-as-directory frompath))
	  (setq dir (file-name-directory (directory-file-name frompath)))
	  (setq frompath (file-name-nondirectory (directory-file-name frompath))))
      (setq args "-9q")
      (setq dir (file-name-directory frompath))
      (setq frompath (file-name-nondirectory frompath)))
    (with-temp-buffer
      (let ((default-directory dir))
	(message "ZIP ...")
	(mew-flet
	 (apply (function call-process)
		"zip" nil t nil
		(list args "-" frompath))
	 (when sfx
	   (goto-char (point-min))
	   (insert-file-contents mew-attach-unzipsfx-prog))
	 (write-region (point-min) (point-max) compfile nil 'nomsg)
	 (when sfx
	   (let ((default-directory (file-name-directory compfile)))
	     (call-process "zip" nil nil nil "-A" (file-name-nondirectory compfile)))))))
    (mew-attach-duplicate (function copy-file) "copy" t compfile)
    (when (and (file-exists-p compfile) (file-writable-p compfile))
      (delete-file compfile))))

後> # さすがは白井さん、暖めてますねぇ。

## 大抵の場合、人に恥ずかしくて人にみせられないものなのだけどね。
## 今回は後藤さんの needs とマッチしたから ^^;;;

-- 
白井秀行 (mailto:shirai at example.com)



Mew-win32 メーリングリストの案内