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)))
78 (defun raw-text-insert-file-contents (filename
79 &optional visit beg end replace)
80 "Like `insert-file-contents', q.v., but don't code and format conversion.
81 Like `insert-file-contents-literary', but it allows find-file-hooks,
82 automatic uncompression, etc.
83 Like `binary-insert-file-contents', but it converts line-break
85 (let ((coding-system-for-read 'raw-text)
87 ;; Returns list of absolute file name and length of data inserted.
88 (insert-file-contents filename visit beg end replace)))
91 (defun raw-message-write-region (start end filename
92 &optional append visit lockname)
93 "Like `write-region', q.v., but write as network representation."
94 (let ((coding-system-for-write 'raw-text-dos)
96 (write-region start end filename append visit lockname)))
104 ;;; raw-io.el ends here