This file is indexed.

/usr/share/gap/pkg/io/doc/chap10.txt is in gap-io 4.5.1+ds-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  
  10 Examples of usage
  
  For larger examples see the example directory of the package. You find there
  a  small  server  using  the  TCP/IP protocol and a corresponding client and
  another small server using the UDP protocol and a corresponding client.
  
  Further,  there  is an example for the usage of File objects, that read from
  or write to strings.
  
  Another  example  there  shows  starting up a child process and piping a few
  megabytes through it using IO_Popen2 (4.4-4).
  
  In  the following, we present a few explicit, interactive short examples for
  the  usage  of the functions in this package. Note that you have to load the
  IO package with the command LoadPackage("IO"); before trying these examples.
  
  
  10.1 Writing and reading a file
  
  The  following  sequence  of commands opens a file with name guck and writes
  some things to it:
  
    Example  
    gap> f := IO_File("guck","w");
    <file fd=3 wbufsize=65536 wdata=0>
    gap> IO_Write(f,"Hello world\n");
    12
    gap> IO_WriteLine(f,"Hello world2!");
    14
    gap> IO_Write(f,12345);
    5
    gap> IO_Flush(f);
    true
    gap> IO_Close(f);
    true
  
  
  There  is  nothing  special  about  this,  the  numbers are numbers of bytes
  written.  Note  that  only  after  the IO_Flush (4.2-10) command the data is
  actually written to disk. Before that, it resides in the write buffer of the
  file. Note further, that the IO_Flush (4.2-10) call here would not have been
  necessary, since the IO_Close (4.2-16) call flushes the buffer anyway.
  
  The file can again be read with the following sequence of commands:
  
    Example  
    gap> f := IO_File("guck","r");
    <file fd=3 rbufsize=65536 rpos=1 rdata=0>
    gap> IO_Read(f,10);
    "Hello worl"
    gap> IO_ReadLine(f);
    "d\n"
    gap> IO_ReadLine(f);
    "Hello world2!\n"
    gap> IO_ReadLine(f);
    "12345"
    gap> IO_ReadLine(f);
    ""
    gap> IO_Close(f);
    true
  
  
  Note  here  that  reading  line-wise  can  only be done efficiently by using
  buffered  I/O.  You  can  mix  calls  to  IO_Read (4.2-6) and to IO_ReadLine
  (4.2-3).  The end of file is indicated by an empty string returned by one of
  the read functions.
  
  
  10.2 Using filtering programs to read and write files
  
  If you want to write a big amount of data to file you might want to compress
  it  on  the fly without using much disk space. This can be achieved with the
  following command:
  
    Example  
    gap> s := "";; for i in [1..10000] do Append(s,String(i)); od;;
    gap> Length(s);
    38894
    gap> IO_FileFilterString("guck.gz",[["gzip",["-9c"]]],s);
    true
    gap> sgz := StringFile("guck.gz");;
    gap> Length(sgz);
    18541
    gap> ss := IO_StringFilterFile([["gzip",["-dc"]]],"guck.gz");;
    gap> s=ss;
    true
  
  
  This  sequence  of commands needs that the program gzip is installed on your
  system.
  
  
  10.3 Using filters when reading or writing files sequentially
  
  If  you  want  to process bigger amounts of data you might not want to store
  all  of  it  in a single GAP string. In that case you might want to access a
  file on disk sequentially through a filter:
  
    Example  
    gap> f := IO_FilteredFile([["gzip",["-9c"]]],"guck.gz","w");
    <file fd=5 wbufsize=65536 wdata=0>
    gap> IO_Write(f,"Hello world!\n");
    13
    gap> IO_Write(f,Elements(SymmetricGroup(5)),"\n");
    1359
    gap> IO_Close(f);
    true
    gap> f := IO_FilteredFile([["gzip",["-dc"]]],"guck.gz","r");
    <file fd=4 rbufsize=65536 rpos=1 rdata=0>
    gap> IO_ReadLine(f);
    "Hello world!\n"
    gap> s := IO_ReadLine(f);; Length(s);
    1359
    gap> IO_Read(f,10);
    ""
    gap> IO_Close(f);
    true
  
  
  
  10.4 Accessing a web page
  
  The  IO package has an HTTP client implementation. Using this you can access
  web pages and other web downloads from within GAP. Here is an example:
  
    Example  
    gap> r := SingleHTTPRequest("www.math.rwth-aachen.de",80,"GET",
    >              "/~Max.Neunhoeffer/index.html",rec(),false,false);;
    gap> RecNames(r);
    [ "protoversion", "statuscode", "status", "header", "body", "closed" ]
    gap> r.status;
    "OK"
    gap> r.statuscode;
    200
    gap> r.header;
    rec( date := "Thu, 07 Dec 2006 22:08:22 GMT",
      server := "Apache/2.0.55 (Ubuntu)",
      last-modified := "Thu, 16 Nov 2006 00:21:44 GMT",
      etag := "\"2179cf-11a5-3c77f600\"", accept-ranges := "bytes",
      content-length := "4517", content-type := "text/html; charset=ISO-8859-1" )
    gap> Length(r.body);
    4517
  
  
  Of course, the time stamps and exact sizes of the answer may differ when you
  do this.
  
  
  10.5 (Un-)Pickling
  
  Assume  you  have  some  GAP  objects  you  want  to archive to disk grouped
  together. Then you might do the following:
  
    Example  
    gap> r := rec( a := 1, b := "Max", c := [1,2,3] );
    rec( a := 1, b := "Max", c := [ 1, 2, 3 ] )
    gap> r.c[4] := r;
    rec( a := 1, b := "Max", c := [ 1, 2, 3, ~ ] )
    gap> f := IO_File("guck","w");
    <file fd=3 wbufsize=65536 wdata=0>
    gap> IO_Pickle(f,r);
    IO_OK
    gap> IO_Pickle(f,[(1,2,3,4),(3,4)]);
    IO_OK
    gap> IO_Close(f);
    true
  
  
  Then, to read it in again, just do:
  
    Example  
    gap> f := IO_File("guck");
    <file fd=3 rbufsize=65536 rpos=1 rdata=0>
    gap> IO_Unpickle(f);
    rec( a := 1, b := "Max", c := [ 1, 2, 3, ~ ] )
    gap> IO_Unpickle(f);
    [ (1,2,3,4), (3,4) ]
    gap> IO_Unpickle(f);
    IO_Nothing
    gap> IO_Close(f);
    true
  
  
  Note that this works for a certain amount of builtin objects. If you want to
  archive  your  own  objects  or  more  sophisticated objects you have to use
  extend  the functionality as explained in Section 5.3. However, it works for
  lists and records and they may be arbitrarily self-referential.