File: binary.sl

package info (click to toggle)
jed 0.98.7-14
  • links: PTS
  • area: main
  • in suites: slink
  • size: 3,088 kB
  • ctags: 3,851
  • sloc: ansic: 29,315; makefile: 257; sh: 248
file content (29 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
% It is used to read a file in binary mode.

define find_binary_file ()
{   
   variable file, bytes, len, pos;
   
   file = read_file_from_mini ("Find Binary File:");
   ERROR_BLOCK
     {
	set_file_translation (0);
     }
   set_file_translation (1);
   find_file(file); pop();
   EXECUTE_ERROR_BLOCK;
   no_mode();
   set_overwrite(1);
   %
   %  set the binary file flags
   getbuf_info();
   setbuf_info(() | 0x200);
   
   bytes = count_chars();
   if (string_match(bytes, ".*of \\([0-9]+\\)$", 1))
     {
	(pos, len) = string_match_nth(1);
	bytes = substr(bytes, pos + 1, len);
	message (bytes + " bytes.");
     }
}