1 ;;; raw-io.el --- input/output without code-conversion
3 ;; Copyright (C) 1997,1998,1999,2000 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
6 ;; Keywords: definition, MIME, multimedia, mail, news
8 ;; This file is part of APEL (A Portable Emacs Library).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (eval-when-compile (require 'static))
29 (static-if (and (featurep 'xemacs)
30 (not (featurep 'utf-2000)))
31 (defun binary-insert-file-contents (filename
32 &optional visit beg end replace)
33 "Like `insert-file-contents', but only reads in the file literally.
34 A buffer may be modified in several ways after reading into the buffer,
35 to Emacs features such as format decoding, character code
36 conversion, find-file-hooks, automatic uncompression, etc.
38 This function ensures that none of these modifications will take place."
39 (let ((format-alist nil)
40 (after-insert-file-functions nil)
41 (coding-system-for-read 'binary)
42 (coding-system-for-write 'binary)
43 (jka-compr-compression-info-list nil)
44 (jam-zcat-filename-list nil)
45 (find-buffer-file-type-function
46 (if (fboundp 'find-buffer-file-type)
47 (symbol-function 'find-buffer-file-type)
51 (fset 'find-buffer-file-type (lambda (filename) t))
52 (insert-file-contents filename visit beg end replace))
53 (if find-buffer-file-type-function
54 (fset 'find-buffer-file-type find-buffer-file-type-function)
55 (fmakunbound 'find-buffer-file-type)))))
56 (defalias 'binary-insert-file-contents 'insert-file-contents-literally))
58 (defun binary-write-region (start end filename
59 &optional append visit lockname)
60 "Like `write-region', q.v., but don't encode."
61 (let ((coding-system-for-write 'binary)
62 jka-compr-compression-info-list jam-zcat-filename-list)
63 (write-region start end filename append visit lockname)))
65 (defun binary-find-file-noselect (filename &optional nowarn rawfile)
66 "Like `find-file-noselect', q.v., but don't code and format conversion."
67 (let ((coding-system-for-read 'binary)
69 (find-file-noselect filename nowarn rawfile)))
71 (defun binary-open-network-stream (name buffer host service &rest options)
72 "Like `open-network-stream', q.v., but don't code and format conversion."
73 (let ((coding-system-for-read 'binary)
74 (coding-system-for-write 'binary))
75 (apply #'open-network-stream name buffer host service options)))
77 (defun binary-start-process (name buffer program &rest program-args)
78 "Like `start-process', q.v., but don't code conversion."
79 (let ((coding-system-for-read 'binary)
80 (coding-system-for-write 'binary))
81 (apply '#start-process name buffer program program-args)))
83 (defun binary-start-process-shell-command (name buffer &rest args)
84 "Like `start-process-shell-command', q.v., but don't code conversion."
85 (let ((coding-system-for-read 'binary)
86 (coding-system-for-write 'binary))
87 (apply '#start-process-shell-command name buffer args)))
90 (defun raw-text-insert-file-contents (filename
91 &optional visit beg end replace)
92 "Like `insert-file-contents', q.v., but don't code and format conversion.
93 Like `insert-file-contents-literary', but it allows find-file-hooks,
94 automatic uncompression, etc.
95 Like `binary-insert-file-contents', but it converts line-break
97 (let ((coding-system-for-read 'raw-text)
99 ;; Returns list of absolute file name and length of data inserted.
100 (insert-file-contents filename visit beg end replace)))
103 (defun raw-message-write-region (start end filename
104 &optional append visit lockname)
105 "Like `write-region', q.v., but write as network representation."
106 (let ((coding-system-for-write 'raw-text-dos)
108 (write-region start end filename append visit lockname)))
116 ;;; raw-io.el ends here