星火微课系统客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

compress.ps 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. shellarguments % push command line arguments to stack
  2. /tmpstr 65535 string def % define temp buffer
  3. /outstreamRaw % define raw output stream / file with filters (new file)
  4. 2 index (w) file
  5. def
  6. /outstreamRawAppend % define raw output stream / file with filters (append)
  7. 2 index (a) file
  8. def
  9. /instream % define inputstream / file
  10. 3 index (r) file
  11. def
  12. /decodeFilters % decode filters
  13. 4 index
  14. def
  15. /outstreamEncode % define output stream / file with filters
  16. 2 index (a) file
  17. 6 index cvx exec
  18. def
  19. /compress
  20. {
  21. (%!\ncurrentfile) outstreamRaw exch writestring % header, no filers for header
  22. decodeFilters outstreamRaw exch writestring % header
  23. ( cvx exec\n) outstreamRaw exch writestring % header
  24. outstreamRaw closefile
  25. {
  26. instream
  27. tmpstr readstring not
  28. {
  29. outstreamEncode exch writestring
  30. exit
  31. } if
  32. outstreamEncode exch writestring
  33. } loop
  34. outstreamEncode closefile
  35. instream closefile
  36. flush
  37. (~>) outstreamRawAppend exch writestring % End
  38. outstreamRawAppend closefile
  39. } bind def
  40. compress