1 (in-package :lambda-utils
)
7 (defparameter *mime-types
*
8 #{"3dm" "x-world/x-3dmf"
9 "3dmf" "x-world/x-3dmf"
10 "a" "application/octet-stream"
11 "aab" "application/x-authorware-bin"
12 "aam" "application/x-authorware-map"
13 "aas" "application/x-authorware-seg"
16 "afl" "video/animaflex"
17 "ai" "application/postscript"
21 "aim" "application/x-aim"
22 "aip" "text/x-audiosoft-intra"
23 "ani" "application/x-navi-animation"
24 "aos" "application/x-nokia-9000-communicator-add-on-software"
25 "aps" "application/mime"
26 "arj" "application/arj"
28 "asf" "video/x-ms-asf"
31 "asx" "video/x-ms-asf"
34 "avs" "video/avs-video"
35 "bcpio" "application/x-bcpio"
36 "bin" "application/octet-stream"
39 "boo" "application/book"
40 "book" "application/book"
41 "boz" "application/x-bzip2"
42 "bsh" "application/x-bsh"
43 "bz" "application/x-bzip"
44 "bz2" "application/x-bzip2"
48 "ccad" "application/clariscad"
49 "cco" "application/x-cocoa"
50 "cdf" "application/cdf"
51 "cer" "application/x-x509-ca-cert"
52 "cha" "application/x-chat"
53 "chat" "application/x-chat"
54 "class" "application/java-byte-code"
55 "csv" "text/comma-separated-value"
56 "com" "application/octet-stream"
58 "cpio" "application/x-cpio"
60 "cpt" "application/mac-compactpro"
61 "crl" "application/pkcs-crl"
62 "crt" "application/x-x509-user-cert"
63 "csh" "application/x-csh"
67 "dcr" "application/x-director"
68 "deepv" "application/x-deepv"
70 "der" "application/x-x509-ca-cert"
72 "dir" "application/x-director"
75 "doc" "application/msword"
76 "dot" "application/msword"
77 "dp" "application/commonground"
78 "drw" "application/drafting"
79 "dump" "application/octet-stream"
81 "dvi" "application/x-dvi"
83 "dwg" "application/acad"
84 "dxf" "application/dxf"
85 "dxr" "application/x-director"
86 "el" "text/x-script.elisp"
87 "elc" "application/x-bytecode.elisp"
88 "elc" "application/x-elc"
89 "env" "application/x-envoy"
90 "eps" "application/postscript"
91 "es" "application/x-esrehber"
93 "evy" "application/envoy"
94 "exe" "application/octet-stream"
96 "f77" "text/x-fortran"
97 "f90" "text/x-fortran"
98 "fdf" "application/vnd.fdf"
99 "fif" "application/fractals"
103 "flo" "image/florian"
104 "flx" "text/vnd.fmi.flexstor"
105 "fmf" "video/x-atomic3d-feature"
107 "for" "text/x-fortran"
108 "fpx" "image/vnd.fpx"
109 "frl" "application/freeloader"
118 "gsp" "application/x-gsp"
119 "gss" "application/x-gss"
120 "gtar" "application/x-gtar"
121 "gz" "application/x-gzip"
122 "gzip" "application/x-gzip"
124 "hdf" "application/x-hdf"
125 "help" "application/x-helpfile"
126 "hgl" "application/vnd.hp-hpgl"
129 "hlb" "text/x-script"
130 "hlp" "application/x-helpfile"
131 "hpg" "application/vnd.hp-hpgl"
132 "hpgl" "application/vnd.hp-hpgl"
133 "hqx" "application/binhex"
134 "hta" "application/hta"
135 "htc" "text/x-component"
139 "htt" "text/webviewhtml"
141 "ice" "x-conference/x-cooltalk"
146 "iges" "application/iges"
147 "igs" "application/iges"
148 "ima" "application/x-ima"
149 "imap" "application/x-httpd-imap"
150 "inf" "application/inf"
151 "ins" "application/x-internett-signup"
152 "ip" "application/x-ip2"
153 "isu" "video/x-isvideo"
155 "iv" "application/x-inventor"
156 "ivr" "i-world/i-vrml"
157 "ivy" "application/x-livescreen"
161 "jcm" "application/x-java-commerce"
163 "jfif-tb" "image/jpeg"
168 "js" "application/x-javascript"
169 "jut" "image/jutvision"
171 "ksh" "application/x-ksh"
172 "la" "audio/nspaudio"
173 "lam" "audio/x-liveaudio"
174 "latex" "application/x-latex"
175 "lisp" "application/x-lisp"
176 "lha" "application/lha"
177 "lhx" "application/octet-stream"
179 "lma" "audio/nspaudio"
181 "lsp" "application/x-lisp"
183 "lsx" "text/x-la-asf"
184 "ltx" "application/x-latex"
185 "lzh" "application/x-lzh"
186 "lzx" "application/lzx"
187 "lzx" "application/x-lzx"
192 "m3u" "audio/x-mpequrl"
193 "man" "application/x-troff-man"
194 "map" "application/x-navimap"
196 "mbd" "application/mbedlet"
197 "mc$" "application/x-magic-cap-package-1.0"
198 "mcd" "application/mcad"
199 "mcd" "application/x-mathcad"
201 "mcp" "application/netmc"
202 "me" "application/x-troff-me"
203 "mht" "message/rfc822"
204 "mhtml" "message/rfc822"
205 "mid" "application/x-midi"
208 "mif" "application/x-frame"
210 "mjf" "audio/x-vnd.audioexplosion.mjuicemediafile"
211 "mjpg" "video/x-motion-jpeg"
212 "mm" "application/base64"
213 "mme" "application/base64"
215 "moov" "video/quicktime"
216 "mov" "video/quicktime"
217 "movie" "video/x-sgi-movie"
221 "mpc" "application/x-project"
226 "mpp" "application/vnd.ms-project"
227 "mpt" "application/x-project"
228 "mpv" "application/x-project"
229 "mpx" "application/x-project"
230 "mrc" "application/marc"
231 "ms" "application/x-troff-ms"
232 "mv" "video/x-sgi-movie"
234 "mzz" "application/x-vnd.audioexplosion.mzz"
236 "naplps"" image/naplps"
237 "nc" "application/x-netcdf"
238 "ncm" "application/vnd.nokia.configuration-message"
240 "niff" "image/x-niff"
241 "nix" "application/x-mix-transfer"
242 "nsc" "application/x-conference"
243 "nvd" "application/x-navidoc"
244 "o" "application/octet-stream"
245 "oda" "application/oda"
246 "omc" "application/x-omc"
247 "omcd" "application/x-omcdatamaker"
248 "omcr" "application/x-omcregerator"
250 "p10" "application/pkcs10"
251 "p12" "application/pkcs-12"
252 "p7a" "application/x-pkcs7-signature"
253 "p7c" "application/pkcs7-mime"
254 "p7m" "application/pkcs7-mime"
255 "p7r" "application/x-pkcs7-certreqresp"
256 "p7s" "application/pkcs7-signature"
257 "part" "application/pro_eng"
259 "pbm" "image/x-portable-bitmap"
260 "pcl" "application/x-pcl"
263 "pdb" "chemical/x-pdb"
264 "pdf" "application/pdf"
266 "pfunk" "audio/make.my.funk"
267 "pgm" "image/x-portable-graymap"
270 "pkg" "application/x-newton-compatible-pkg"
271 "pko" "application/vnd.ms-pki.pko"
273 "pl" "text/x-script.perl"
274 "plx" "application/x-pixclscript"
275 "pm" "image/x-xpixmap"
276 "pm" "text/x-script.perl-module"
277 "pm4" "application/x-pagemaker"
278 "pm5" "application/x-pagemaker"
280 "pnm" "image/x-portable-anymap"
281 "pot" "application/mspowerpoint"
283 "ppa" "application/vnd.ms-powerpoint"
284 "ppm" "image/x-portable-pixmap"
285 "pps" "application/mspowerpoint"
286 "pps" "application/vnd.ms-powerpoint"
287 "ppt" "application/mspowerpoint"
288 "ppz" "application/mspowerpoint"
289 "pre" "application/x-freelance"
290 "prt" "application/pro_eng"
291 "ps" "application/postscript"
292 "psd" "application/octet-stream"
294 "pwz" "application/vnd.ms-powerpoint"
295 "py" "text/x-script.phyton"
296 "pyc" "applicaiton/x-bytecode.python"
297 "qcp" "audio/vnd.qcelp"
298 "qd3" "x-world/x-3dmf"
299 "qd3d" "x-world/x-3dmf"
300 "qif" "image/x-quicktime"
301 "qt" "video/quicktime"
303 "qti" "image/x-quicktime"
304 "qtif" "image/x-quicktime"
305 "ra" "audio/x-realaudio"
306 "ram" "audio/x-pn-realaudio"
307 "ras" "image/cmu-raster"
308 "rast" "image/cmu-raster"
309 "rexx" "text/x-script.rexx"
310 "rf" "image/vnd.rn-realflash"
312 "rm" "audio/x-pn-realaudio"
314 "rmm" "audio/x-pn-realaudio"
315 "rmp" "audio/x-pn-realaudio"
316 "rng" "application/ringing-tones"
317 "rnx" "application/vnd.rn-realplayer"
318 "roff" "application/x-troff"
319 "rp" "image/vnd.rn-realpix"
320 "rpm" "audio/x-pn-realaudio-plugin"
322 "rtf" "text/richtext"
323 "rtx" "text/richtext"
324 "rv" "video/vnd.rn-realvideo"
327 "saveme" "application/octet-stream"
328 "sbk" "application/x-tbook"
329 "scm" "text/x-script.scheme"
332 "sdp" "application/sdp"
333 "sdr" "application/sounder"
334 "sea" "application/sea"
335 "set" "application/set"
338 "sh" "application/x-sh"
339 "shar" "application/x-shar"
342 "sit" "application/x-stuffit"
343 "skd" "application/x-koan"
344 "skm" "application/x-koan"
345 "skp" "application/x-koan"
346 "skt" "application/x-koan"
347 "sl" "application/x-seelogo"
348 "smi" "application/smil"
349 "smil" "application/smil"
351 "snd" "audio/x-adpcm"
352 "sol" "application/solids"
353 "spc" "application/x-pkcs7-certificates"
354 "spl" "application/futuresplash"
355 "spr" "application/x-sprite"
356 "sprite" "application/x-sprite"
357 "src" "application/x-wais-source"
358 "ssi" "text/x-server-parsed-html"
359 "ssm" "application/streamingmedia"
360 "sst" "application/vnd.ms-pki.certstore"
361 "step" "application/step"
362 "stl" "application/x-navistyle"
363 "stp" "application/step"
364 "sv4cpio"" application/x-sv4cpio"
365 "sv4crc"" application/x-sv4crc"
367 "svr" "application/x-world"
368 "swf" "application/x-shockwave-flash"
369 "t" "application/x-troff"
370 "talk" "text/x-speech"
371 "tar" "application/x-tar"
372 "tbk" "application/toolbook"
373 "tbk" "application/x-tbook"
374 "tcl" "application/x-tcl"
375 "tcsh" "text/x-script.tcsh"
376 "tex" "application/x-tex"
377 "texi" "application/x-texinfo"
378 "texinfo" "application/x-texinfo"
380 "tgz" "application/gnutar"
383 "tr" "application/x-troff"
384 "tsi" "audio/tsp-audio"
385 "tsp" "audio/tsplayer"
386 "tsv" "text/tab-separated-values"
387 "turbot" "image/florian"
390 "uni" "text/uri-list"
391 "unis" "text/uri-list"
392 "unv" "application/i-deas"
393 "uri" "text/uri-list"
394 "uris" "text/uri-list"
395 "ustar" "application/x-ustar"
396 "uu" "text/x-uuencode"
397 "uue" "text/x-uuencode"
398 "vcd" "application/x-cdlink"
399 "vcs" "text/x-vcalendar"
400 "vda" "application/vda"
402 "vew" "application/groupwise"
405 "vmd" "application/vocaltec-media-desc"
406 "vmf" "application/vocaltec-media-file"
409 "vox" "audio/voxware"
410 "vqe" "audio/x-twinvq-plugin"
411 "vqf" "audio/x-twinvq"
412 "vql" "audio/x-twinvq-plugin"
414 "vrt" "x-world/x-vrt"
415 "vsd" "application/x-visio"
416 "vst" "application/x-visio"
417 "vsw" "application/x-visio"
418 "w60" "application/wordperfect6.0"
419 "w61" "application/wordperfect6.1"
420 "w6w" "application/msword"
422 "wb1" "application/x-qpro"
423 "wbmp" "image/vnd.wap.wbmp"
424 "web" "application/vnd.xara"
425 "wiz" "application/msword"
426 "wk1" "application/x-123"
427 "wmf" "windows/metafile"
428 "wml" "text/vnd.wap.wml"
429 "wmlc" "application/vnd.wap.wmlc"
430 "wmls" "text/vnd.wap.wmlscript"
431 "wmlsc" "application/vnd.wap.wmlscriptc"
432 "word" "application/msword"
433 "wp" "application/wordperfect"
434 "wp5" "application/wordperfect"
435 "wp5" "application/wordperfect6.0"
436 "wp6" "application/wordperfect"
437 "wpd" "application/wordperfect"
438 "wq1" "application/x-lotus"
439 "wri" "application/mswrite"
442 "wsc" "text/scriplet"
443 "wsrc" "application/x-wais-source"
444 "wtk" "application/x-wintalk"
445 "xbm" "image/x-xbitmap"
446 "xdr" "video/x-amt-demorun"
448 "xif" "image/vnd.xiff"
449 "xl" "application/excel"
450 "xla" "application/excel"
451 "xlb" "application/excel"
452 "xlc" "application/excel"
453 "xld" "application/excel"
454 "xlk" "application/excel"
455 "xll" "application/excel"
456 "xlm" "application/excel"
457 "xls" "application/excel"
458 "xlt" "application/excel"
459 "xlv" "application/excel"
460 "xlw" "application/excel"
464 "xpix" "application/x-vnd.ls-xpix"
467 "xsr" "video/x-amt-showrun"
469 "xyz" "chemical/x-pdb"
470 "z" "application/x-compressed"
471 "zip" "application/zip"
472 "zoo" "application/octet-stream"
473 "zsh" "text/x-script.zsh"})
476 (defun mime-type (filename)
477 (or (gethash (pathname-type (pathname filename
)) *mime-types
*)
478 "application/octet-stream"))
484 (defparameter *mime-handlers
* #{
485 "application/octet-stream" :binary
486 "application/x-sprite" :binary
487 "application/x-sv4crc" :binary
488 "image/florian" :binary
489 "image/naplps" :binary
490 "application/x-sv4cpio" :binary
491 "application/x-texinfo" :binary
492 "applicaiton/x-bytecode.python" :binary
493 "application/acad" :binary
494 "application/arj" :binary
495 "application/base64" :binary
496 "application/binhex" :binary
497 "application/book" :binary
498 "application/cdf" :binary
499 "application/clariscad" :binary
500 "application/commonground" :binary
501 "application/drafting" :binary
502 "application/dxf" :binary
503 "application/envoy" :binary
504 "application/excel" :binary
505 "application/fractals" :binary
506 "application/freeloader" :binary
507 "application/futuresplash" :binary
508 "application/gnutar" :binary
509 "application/groupwise" :binary
510 "application/hta" :binary
511 "application/i-deas" :binary
512 "application/iges" :binary
513 "application/inf" :binary
514 "application/java-byte-code" :binary
515 "application/lha" :binary
516 "application/lzx" :binary
517 "application/mac-compactpro" :binary
518 "application/marc" :binary
519 "application/mbedlet" :binary
520 "application/mcad" :binary
521 "application/mime" :binary
522 "application/mspowerpoint" :binary
523 "application/msword" :binary
524 "application/mswrite" :binary
525 "application/netmc" :binary
526 "application/octet-stream" :binary
527 "application/oda" :binary
528 "application/pdf" :binary
529 "application/pkcs-12" :binary
530 "application/pkcs-crl" :binary
531 "application/pkcs10" :binary
532 "application/pkcs7-mime" :binary
533 "application/pkcs7-signature" :binary
534 "application/pkix-cert" :binary
535 "application/postscript" :binary
536 "application/pro_eng" :binary
537 "application/ringing-tones" :binary
538 "application/sdp" :binary
539 "application/sea" :binary
540 "application/set" :binary
541 "application/smil" :binary
542 "application/solids" :binary
543 "application/sounder" :binary
544 "application/step" :binary
545 "application/streamingmedia" :binary
546 "application/toolbook" :binary
547 "application/vda" :binary
548 "application/vnd.fdf" :binary
549 "application/vnd.hp-hpgl" :binary
550 "application/vnd.ms-pki.certstore" :binary
551 "application/vnd.ms-pki.pko" :binary
552 "application/vnd.ms-powerpoint" :binary
553 "application/vnd.ms-project" :binary
554 "application/vnd.nokia.configuration-message" :binary
555 "application/vnd.rn-realplayer" :binary
556 "application/vnd.wap.wmlc" :binary
557 "application/vnd.wap.wmlscriptc" :binary
558 "application/vnd.xara" :binary
559 "application/vocaltec-media-desc" :binary
560 "application/vocaltec-media-file" :binary
561 "application/wordperfect" :binary
562 "application/wordperfect6.0" :binary
563 "application/wordperfect6.1" :binary
564 "application/x-123" :binary
565 "application/x-aim" :binary
566 "application/x-authorware-bin" :binary
567 "application/x-authorware-map" :binary
568 "application/x-authorware-seg" :binary
569 "application/x-bcpio" :binary
570 "application/x-bsh" :binary
571 "application/x-bytecode.elisp" :binary
572 "application/x-bzip" :binary
573 "application/x-bzip2" :binary
574 "application/x-cdlink" :binary
575 "application/x-chat" :binary
576 "application/x-cocoa" :binary
577 "application/x-compressed" :binary
578 "application/x-conference" :binary
579 "application/x-cpio" :binary
580 "application/x-csh" :binary
581 "application/x-deepv" :binary
582 "application/x-director" :binary
583 "application/x-dvi" :binary
584 "application/x-elc" :binary
585 "application/x-envoy" :binary
586 "application/x-esrehber" :binary
587 "application/x-frame" :binary
588 "application/x-freelance" :binary
589 "application/x-gsp" :binary
590 "application/x-gss" :binary
591 "application/x-gtar" :binary
592 "application/x-hdf" :binary
593 "application/x-helpfile" :binary
594 "application/x-httpd-imap" :binary
595 "application/x-ima" :binary
596 "application/x-internett-signup" :binary
597 "application/x-inventor" :binary
598 "application/x-ip2" :binary
599 "application/x-java-commerce" :binary
600 "application/x-javascript" :binary
601 "application/x-koan" :binary
602 "application/x-livescreen" :binary
603 "application/x-lotus" :binary
604 "application/x-lzh" :binary
605 "application/x-lzx" :binary
606 "application/x-magic-cap-package-1.0" :binary
607 "application/x-mathcad" :binary
608 "application/x-midi" :binary
609 "application/x-mix-transfer" :binary
610 "application/x-navi-animation" :binary
611 "application/x-navidoc" :binary
612 "application/x-navimap" :binary
613 "application/x-navistyle" :binary
614 "application/x-netcdf" :binary
615 "application/x-newton-compatible-pkg" :binary
616 "application/x-nokia-9000-communicator-add-on-software" :binary
617 "application/x-omc" :binary
618 "application/x-omcdatamaker" :binary
619 "application/x-omcregerator" :binary
620 "application/x-pagemaker" :binary
621 "application/x-pcl" :binary
622 "application/x-pixclscript" :binary
623 "application/x-pkcs7-certificates" :binary
624 "application/x-pkcs7-certreqresp" :binary
625 "application/x-pkcs7-signature" :binary
626 "application/x-project" :binary
627 "application/x-qpro" :binary
628 "application/x-seelogo" :binary
629 "application/x-shockwave-flash" :binary
630 "application/x-sprite" :binary
631 "application/x-stuffit" :binary
632 "application/x-tar" :binary
633 "application/x-tbook" :binary
634 "application/x-tcl" :binary
635 "application/x-texinfo" :binary
636 "application/x-troff" :binary
637 "application/x-troff-man" :binary
638 "application/x-troff-me" :binary
639 "application/x-troff-ms" :binary
640 "application/x-ustar" :binary
641 "application/x-visio" :binary
642 "application/x-vnd.audioexplosion.mzz" :binary
643 "application/x-vnd.ls-xpix" :binary
644 "application/x-wais-source" :binary
645 "application/x-wintalk" :binary
646 "application/x-world" :binary
647 "application/x-x509-ca-cert" :binary
648 "application/x-x509-user-cert" :binary
650 "audio/basic" :binary
653 "audio/make.my.funk" :binary
658 "audio/nspaudio" :binary
660 "audio/tsp-audio" :binary
661 "audio/tsplayer" :binary
662 "audio/vnd.qcelp" :binary
664 "audio/voxware" :binary
666 "audio/x-adpcm" :binary
667 "audio/x-gsm" :binary
668 "audio/x-jam" :binary
669 "audio/x-liveaudio" :binary
670 "audio/x-mpequrl" :binary
671 "audio/x-pn-realaudio" :binary
672 "audio/x-pn-realaudio-plugin" :binary
673 "audio/x-psid" :binary
674 "audio/x-realaudio" :binary
675 "audio/x-twinvq" :binary
676 "audio/x-twinvq-plugin" :binary
677 "audio/x-vnd.audioexplosion.mjuicemediafile" :binary
679 "chemical/x-pdb" :binary
680 "i-world/i-vrml" :binary
682 "image/cmu-raster" :binary
684 "image/florian" :binary
685 "image/g3fax" :binary
689 "image/jutvision" :binary
690 "image/naplps" :binary
694 "image/vnd.fpx" :binary
695 "image/vnd.rn-realflash" :binary
696 "image/vnd.rn-realpix" :binary
697 "image/vnd.wap.wbmp" :binary
698 "image/vnd.xiff" :binary
699 "image/x-dwg" :binary
700 "image/x-icon" :binary
702 "image/x-jps" :binary
703 "image/x-niff" :binary
704 "image/x-pcx" :binary
705 "image/x-pict" :binary
706 "image/x-portable-anymap" :binary
707 "image/x-portable-bitmap" :binary
708 "image/x-portable-graymap" :binary
709 "image/x-portable-pixmap" :binary
710 "image/x-quicktime" :binary
711 "image/x-rgb" :binary
712 "image/x-xbitmap" :binary
713 "image/x-xpixmap" :binary
714 "image/x-xwd" :binary
716 "message/rfc822" :binary
717 "model/vnd.dwf" :binary
719 "model/x-pov" :binary
720 "paleovu/x-pv" :binary
721 "video/animaflex" :binary
723 "video/avs-video" :binary
728 "video/quicktime" :binary
731 "video/vnd.rn-realvideo" :binary
732 "video/vosaic" :binary
733 "video/x-amt-demorun" :binary
734 "video/x-amt-showrun" :binary
735 "video/x-atomic3d-feature" :binary
738 "video/x-fli" :binary
740 "video/x-isvideo" :binary
741 "video/x-motion-jpeg" :binary
742 "video/x-ms-asf" :binary
743 "video/x-qtc" :binary
744 "video/x-scm" :binary
745 "video/x-sgi-movie" :binary
746 "windows/metafile" :binary
748 "x-conference/x-cooltalk" :binary
749 "x-world/x-3dmf" :binary
750 "x-world/x-vrt" :binary
751 "xgl/drawing" :binary
753 "text/comma-separated-value" :text
754 "application/x-ksh" :text
755 "application/x-tex" :text
756 "application/x-latex" :text
757 "application/x-lisp" :text
758 "application/x-sh" :text
759 "application/x-shar" :text
766 "text/richtext" :text
767 "text/scriplet" :text
769 "text/tab-separated-values" :text
770 "text/uri-list" :text
772 "text/vnd.fmi.flexstor" :text
773 "text/vnd.wap.wml" :text
774 "text/vnd.wap.wmlscript" :text
775 "text/webviewhtml" :text
777 "text/x-audiosoft-intra" :text
779 "text/x-component" :text
780 "text/x-fortran" :text
782 "text/x-la-asf" :text
783 "text/x-pascal" :text
784 "text/x-script" :text
785 "text/x-script.elisp" :text
786 "text/x-script.perl" :text
787 "text/x-script.perl-module" :text
788 "text/x-script.phyton" :text
789 "text/x-script.rexx" :text
790 "text/x-script.scheme" :text
791 "text/x-script.tcsh" :text
792 "text/x-script.zsh" :text
793 "text/x-server-parsed-html" :text
794 "text/x-setext" :text
795 "text/x-speech" :text
797 "text/x-uuencode" :text
798 "text/x-vcalendar" :text
800 "application/zip" :binary
801 "application/x-gzip" :gzip
})
803 (defgeneric typed-open
* (filename file-type direction args
)
804 (:documentation
"Open file according file-type"))
806 (defmethod typed-open* (filename (file-type (eql :text
)) direction args
)
807 (apply #'open
(nconc `(,filename
:direction
,direction
) args
)))
809 ;; TODO: add apropriate typed-open method for xml type
810 (defmethod typed-open* (filename (file-type (eql :xml
)) direction args
)
811 (apply #'open
(nconc `(,filename
) args
)))
813 (defmethod typed-open* (filename (file-type (eql :binary
)) direction args
)
814 (apply #'open
(nconc `(,filename
:element-type
(unsigned-byte 8)) args
)))
816 (defmethod typed-open* (filename (file-type (eql :gzip
)) (direction (eql :input
)) args
)
818 (make-gzip-input-stream
820 `(,filename
:element-type
(unsigned-byte 8))
822 (make-flexi-stream gzip-stream
:external-format
*default-external-format
*)))
824 (defun mime-handler (mime)
825 (or (gethash mime
*mime-handlers
*)
828 (defun typed-open (filename &rest args
&key mime
(direction :input
) &allow-other-keys
)
829 "Open file according file-type and return (values stream mime-type)"
831 (setf mime
(mime-type filename
)))
833 (values (typed-open* filename
(mime-handler mime
) direction args
)
839 (defmacro with-open-typed-file
((var path
&rest options
)
841 (let ((abortp (gensym "abort")))
842 `(let ((,var
(typed-open ,path
,@options
))
845 (multiple-value-prog1 (progn ,@body
)
847 (close ,var
:abort
,abortp
)))))