dump_file.anubis 902 Bytes

   
   

   Dumping the content of a file. 
   
   
define One
   dump
     (
       RStream    file, 
       Word32     n               // current offset in file
     ) =
   if *file is 
     {
       failure then print("\n\n"), 
       success(c) then 
         (if (n&15) = 0
          then print("\n"+to_hexa(n)+" ")
          else unique); 
         (if (n&3) = 0
          then print("  ")
          else unique); 
         print(to_hexa(c)+" ");
         dump(file,n+1)
     }. 
   
   
define One 
   dump
     (
       String filename
     ) =
   if file(filename,read) is 
     {
       failure then print("'"+filename+"' not found.\n"),
       success(fp) then dump(fp,0)
     }. 
   
   
global define One
   dump_file
     (
       List(String) args
     ) =
   if args is 
     {
       [ ] then print("Usage: dump_file <file name>\n"), 
       [h . _] then dump(h)
     }.