Debian Codegraph @

doc/ref/chap9.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <head>
8 <title>GAP (ref) - Chapter 9: Files and Filenames</title>
9 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
10 <meta name="generator" content="GAPDoc2HTML" />
11 <link rel="stylesheet" type="text/css" href="manual.css" />
12 <script src="manual.js" type="text/javascript"></script>
13 <script type="text/javascript">overwriteStyle();</script>
14 </head>
15 <body class="chap9" onload="jscontent()">
16
17
18 <div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a> <a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chap6.html">6</a> <a href="chap7.html">7</a> <a href="chap8.html">8</a> <a href="chap9.html">9</a> <a href="chap10.html">10</a> <a href="chap11.html">11</a> <a href="chap12.html">12</a> <a href="chap13.html">13</a> <a href="chap14.html">14</a> <a href="chap15.html">15</a> <a href="chap16.html">16</a> <a href="chap17.html">17</a> <a href="chap18.html">18</a> <a href="chap19.html">19</a> <a href="chap20.html">20</a> <a href="chap21.html">21</a> <a href="chap22.html">22</a> <a href="chap23.html">23</a> <a href="chap24.html">24</a> <a href="chap25.html">25</a> <a href="chap26.html">26</a> <a href="chap27.html">27</a> <a href="chap28.html">28</a> <a href="chap29.html">29</a> <a href="chap30.html">30</a> <a href="chap31.html">31</a> <a href="chap32.html">32</a> <a href="chap33.html">33</a> <a href="chap34.html">34</a> <a href="chap35.html">35</a> <a href="chap36.html">36</a> <a href="chap37.html">37</a> <a href="chap38.html">38</a> <a href="chap39.html">39</a> <a href="chap40.html">40</a> <a href="chap41.html">41</a> <a href="chap42.html">42</a> <a href="chap43.html">43</a> <a href="chap44.html">44</a> <a href="chap45.html">45</a> <a href="chap46.html">46</a> <a href="chap47.html">47</a> <a href="chap48.html">48</a> <a href="chap49.html">49</a> <a href="chap50.html">50</a> <a href="chap51.html">51</a> <a href="chap52.html">52</a> <a href="chap53.html">53</a> <a href="chap54.html">54</a> <a href="chap55.html">55</a> <a href="chap56.html">56</a> <a href="chap57.html">57</a> <a href="chap58.html">58</a> <a href="chap59.html">59</a> <a href="chap60.html">60</a> <a href="chap61.html">61</a> <a href="chap62.html">62</a> <a href="chap63.html">63</a> <a href="chap64.html">64</a> <a href="chap65.html">65</a> <a href="chap66.html">66</a> <a href="chap67.html">67</a> <a href="chap68.html">68</a> <a href="chap69.html">69</a> <a href="chap70.html">70</a> <a href="chap71.html">71</a> <a href="chap72.html">72</a> <a href="chap73.html">73</a> <a href="chap74.html">74</a> <a href="chap75.html">75</a> <a href="chap76.html">76</a> <a href="chap77.html">77</a> <a href="chap78.html">78</a> <a href="chap79.html">79</a> <a href="chap80.html">80</a> <a href="chap81.html">81</a> <a href="chap82.html">82</a> <a href="chap83.html">83</a> <a href="chap84.html">84</a> <a href="chap85.html">85</a> <a href="chap86.html">86</a> <a href="chap87.html">87</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
19
20 <div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap8.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap10.html">[Next Chapter]</a>&nbsp; </div>
21
22 <p id="mathjaxlink" class="pcenter"><a href="chap9_mj.html">[MathJax on]</a></p>
23 <p><a id="X82BCD4297920C903" name="X82BCD4297920C903"></a></p>
24 <div class="ChapSects"><a href="chap9.html#X82BCD4297920C903">9 <span class="Heading">Files and Filenames</span></a>
25 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X83D8AAA484EE95D9">9.1 <span class="Heading">Portability</span></a>
26 </span>
27 <div class="ContSSBlock">
28 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X87D278437A916905">9.1-1 LastSystemError</a></span>
29 </div></div>
30 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X7A4973627A5DB27D">9.2 <span class="Heading">GAP Root Directories</span></a>
31 </span>
32 </div>
33 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X8223D52E78AF4420">9.3 <span class="Heading">GAP Package Directories</span></a>
34 </span>
35 </div>
36 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X85030B35865A1080">9.4 <span class="Heading">Directories</span></a>
37 </span>
38 <div class="ContSSBlock">
39 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X82B3E24683942597">9.4-1 IsDirectory</a></span>
40 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86A71E927EEC7EAD">9.4-2 Directory</a></span>
41 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8222B1A886E6195E">9.4-3 DirectoryTemporary</a></span>
42 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7BAD8036849E8430">9.4-4 DirectoryCurrent</a></span>
43 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X81DDD2E87F68E086">9.4-5 ChangeDirectoryCurrent</a></span>
44 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X87ED469A85343A3C">9.4-6 DirectoriesLibrary</a></span>
45 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X808E2C187DD984B4">9.4-7 DirectoriesSystemPrograms</a></span>
46 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7B225E5282534EDA">9.4-8 DirectoryContents</a></span>
47 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86F4A32C83B82369">9.4-9 DirectoryDesktop</a></span>
48 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7B0D818A808A3481">9.4-10 DirectoryHome</a></span>
49 </div></div>
50 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X8545E03E7D651456">9.5 <span class="Heading">File Names</span></a>
51 </span>
52 <div class="ContSSBlock">
53 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E352E1F87060602">9.5-1 <span class="Heading">Filename</span></a>
54 </span>
55 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86C7683E7A2A2146">9.5-2 PathSystemProgram</a></span>
56 </div></div>
57 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X85EC7D9087C481B0">9.6 <span class="Heading">Special Filenames</span></a>
58 </span>
59 </div>
60 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X87271FEF86A6A0F9">9.7 <span class="Heading">File Access</span></a>
61 </span>
62 <div class="ContSSBlock">
63 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8269697A7B927AF1">9.7-1 IsExistingFile</a></span>
64 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E156EC886E11BBC">9.7-2 IsReadableFile</a></span>
65 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8412F485796B25F5">9.7-3 IsWritableFile</a></span>
66 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X83A1AAD58435FC4C">9.7-4 IsExecutableFile</a></span>
67 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7D1BE00F83C4EEE8">9.7-5 IsDirectoryPath</a></span>
68 </div></div>
69 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap9.html#X81A0A4FF842B039B">9.8 <span class="Heading">File Operations</span></a>
70 </span>
71 <div class="ContSSBlock">
72 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8373AC6B7D5F9167">9.8-1 Read</a></span>
73 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7824CB7D7D4BAFBC">9.8-2 ReadAsFunction</a></span>
74 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X86956C577FFEE1F9">9.8-3 <span class="Heading">PrintTo and AppendTo</span></a>
75 </span>
76 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X79813A6686894960">9.8-4 <span class="Heading">LogTo</span></a>
77 </span>
78 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7CAB119378B075B7">9.8-5 <span class="Heading">InputLogTo</span></a>
79 </span>
80 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7A5591D87EAFA6CC">9.8-6 <span class="Heading">OutputLogTo</span></a>
81 </span>
82 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X8241CEAD80415BB9">9.8-7 CrcFile</a></span>
83 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7E63ACA38142BE96">9.8-8 RemoveFile</a></span>
84 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X83F3B0337C7EA5CC">9.8-9 UserHomeExpand</a></span>
85 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X7B450DAD8651FC2B">9.8-10 UserHomeShorten</a></span>
86 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap9.html#X79EE267A7FAF28A6">9.8-11 Reread</a></span>
87 </div></div>
88 </div>
89
90 <h3>9 <span class="Heading">Files and Filenames</span></h3>
91
92 <p>Files are identified by filenames, which are represented in <strong class="pkg">GAP</strong> as strings. Filenames can be created directly by the user or a program, but of course this is operating system dependent.</p>
93
94 <p>Filenames for some files can be constructed in a system independent way using the following functions. This is done by first getting a directory object for the directory the file shall reside in, and then constructing the filename. However, it is sometimes necessary to construct filenames of files in subdirectories relative to a given directory object. In this case the directory separator is <em>always</em> <code class="code">/</code> even under DOS or MacOS.</p>
95
96 <p>Section <a href="chap9.html#X85030B35865A1080"><span class="RefLink">9.4</span></a> describes how to construct directory objects for the common <strong class="pkg">GAP</strong> and system directories. Using the command <code class="func">Filename</code> (<a href="chap9.html#X7E352E1F87060602"><span class="RefLink">9.5-1</span></a>) it is possible to construct a filename pointing to a file in these directories. There are also functions to test for accessibility of files, see <a href="chap9.html#X87271FEF86A6A0F9"><span class="RefLink">9.7</span></a>.</p>
97
98 <p><a id="X83D8AAA484EE95D9" name="X83D8AAA484EE95D9"></a></p>
99
100 <h4>9.1 <span class="Heading">Portability</span></h4>
101
102 <p>For portability filenames and directory names should be restricted to at most 8 alphanumerical characters optionally followed by a dot <code class="code">.</code> and between 1 and 3 alphanumerical characters. Upper case letters should be avoided because some operating systems do not make any distinction between case, so that <code class="code">NaMe</code>, <code class="code">Name</code> and <code class="code">name</code> all refer to the same file whereas some operating systems are case sensitive. To avoid problems only lower case characters should be used.</p>
103
104 <p>Another function which is system-dependent is <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>).</p>
105
106 <p><a id="X87D278437A916905" name="X87D278437A916905"></a></p>
107
108 <h5>9.1-1 LastSystemError</h5>
109
110 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LastSystemError</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
111 <p><code class="func">LastSystemError</code> returns a record describing the last system error that has occurred. This record contains at least the component <code class="code">message</code> which is a string. This message is, however, highly operating system dependent and should only be used as an informational message for the user.</p>
112
113 <p><a id="X7A4973627A5DB27D" name="X7A4973627A5DB27D"></a></p>
114
115 <h4>9.2 <span class="Heading">GAP Root Directories</span></h4>
116
117 <p>When <strong class="pkg">GAP</strong> is started it determines a list of directories which we call the <em><strong class="pkg">GAP</strong> root directories</em>. In a running <strong class="pkg">GAP</strong> session this list can be found in <code class="code">GAPInfo.RootPaths</code>.</p>
118
119 <p>The core part of <strong class="pkg">GAP</strong> knows which files to read relative to its root directories. For example when <strong class="pkg">GAP</strong> wants to read its library file <code class="file">lib/group.gd</code>, it appends this path to each path in <code class="code">GAPInfo.RootPaths</code> until it finds the path of an existing file. The first file found this way is read.</p>
120
121 <p>Any subdirectories named <code class="file">pkg/</code> in one of the directories in <code class="code">GAPInfo.RootPaths</code> are added to <code class="code">GAPInfo.PackageDirectories</code> (see <a href="chap9.html#X8223D52E78AF4420"><span class="RefLink">9.3</span></a>), which controls where <strong class="pkg">GAP</strong> looks for available packages.</p>
122
123 <p>The root directories are specified via one or several of the <code class="code">-l paths</code> command line options, see <a href="chap3.html#X782751D5858A6EAF"><span class="RefLink">3.1</span></a>. Furthermore, by default <strong class="pkg">GAP</strong> automatically prepends a user specific <strong class="pkg">GAP</strong> root directory to the list; this can be avoided by calling <strong class="pkg">GAP</strong> with the <code class="code">-r</code> option. The name of this user specific directory depends on your operating system, it can be found in <code class="code">GAPInfo.UserGapRoot</code>. This directory can be used to tell <strong class="pkg">GAP</strong> about personal preferences, to always load some additional code, to install additional packages, or to overwrite some <strong class="pkg">GAP</strong> files. See <a href="chap3.html#X7FD66F977A3B02DF"><span class="RefLink">3.2</span></a> for more information how to do this. After <strong class="pkg">GAP</strong> has been started, one can add additional root directories via the function <code class="func">ExtendRootDirectories</code> (<a href="chap76.html#X7CD0A2F27D19BA03"><span class="RefLink">76.2-4</span></a>).</p>
124
125 <p><a id="X8223D52E78AF4420" name="X8223D52E78AF4420"></a></p>
126
127 <h4>9.3 <span class="Heading">GAP Package Directories</span></h4>
128
129 <p>When <strong class="pkg">GAP</strong> is started it determines a list of directories potentially containing packages. We refer to these as the <em><strong class="pkg">GAP</strong> package directories</em>. In a running <strong class="pkg">GAP</strong> session this list can be found in <code class="code">GAPInfo.PackageDirectories</code>.</p>
130
131 <p>Every subdirectory <code class="file">pkg</code> in a <strong class="pkg">GAP</strong> root directory is automatically added to this list. Further package directories can be specified via one or several <code class="code">--packagedirs paths</code> command line options, see <a href="chap3.html#X782751D5858A6EAF"><span class="RefLink">3.1</span></a>, or after <strong class="pkg">GAP</strong> has been started via the function <code class="func">ExtendPackageDirectories</code> (<a href="chap76.html#X81BFC5C87EE2E02A"><span class="RefLink">76.2-5</span></a>). The order of the directories in <code class="code">GAPInfo.PackageDirectories</code> is as follows: first the package directories specified via the command line option <code class="code">--packagedirs</code>, then the subdirectories <code class="file">pkg</code> of the <strong class="pkg">GAP</strong> root directories that were known at startup in the same order, and finally the directories added after <strong class="pkg">GAP</strong> has been started.</p>
132
133 <p><strong class="pkg">GAP</strong> looks for available packages by examining each of the directories in <code class="code">GAPInfo.PackageDirectories</code>.</p>
134
135 <p><a id="X85030B35865A1080" name="X85030B35865A1080"></a></p>
136
137 <h4>9.4 <span class="Heading">Directories</span></h4>
138
139 <p><a id="X82B3E24683942597" name="X82B3E24683942597"></a></p>
140
141 <h5>9.4-1 IsDirectory</h5>
142
143 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsDirectory</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
144 <p><code class="func">IsDirectory</code> is a category of directories.</p>
145
146 <p><a id="X86A71E927EEC7EAD" name="X86A71E927EEC7EAD"></a></p>
147
148 <h5>9.4-2 Directory</h5>
149
150 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Directory</code>( <var class="Arg">string</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
151 <p>returns a directory object for the string <var class="Arg">string</var>. <code class="func">Directory</code> understands <code class="code">"."</code> for <q>current directory</q>, that is, the directory in which <strong class="pkg">GAP</strong> was started. It also understands absolute paths.</p>
152
153 <p>If the variable <code class="code">GAPInfo.UserHome</code> is defined (this may depend on the operating system) then <code class="func">Directory</code> understands a string with a leading <code class="code">~</code> (tilde) character for a path relative to the user's home directory (but a string beginning with <code class="code">"~other_user"</code> is <em>not</em> interpreted as a path relative to <code class="code">other_user</code>'s home directory, as in a UNIX shell).</p>
154
155 <p>Paths are otherwise taken relative to the current directory.</p>
156
157 <p><a id="X8222B1A886E6195E" name="X8222B1A886E6195E"></a></p>
158
159 <h5>9.4-3 DirectoryTemporary</h5>
160
161 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryTemporary</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
162 <p>returns a directory object in the category <code class="func">IsDirectory</code> (<a href="chap9.html#X82B3E24683942597"><span class="RefLink">9.4-1</span></a>) for a <em>new</em> temporary directory. This is guaranteed to be newly created and empty immediately after the call to <code class="func">DirectoryTemporary</code>. <strong class="pkg">GAP</strong> will make a reasonable effort to remove this directory upon termination of the <strong class="pkg">GAP</strong> job that created the directory.</p>
163
164 <p>If <code class="func">DirectoryTemporary</code> is unable to create a new directory, <code class="keyw">fail</code> is returned. In this case <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>
165
166 <p>A warning message is given if more than 1000 temporary directories are created in any <strong class="pkg">GAP</strong> session.</p>
167
168 <p><a id="X7BAD8036849E8430" name="X7BAD8036849E8430"></a></p>
169
170 <h5>9.4-4 DirectoryCurrent</h5>
171
172 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryCurrent</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
173 <p>returns the directory object for the current directory.</p>
174
175 <p><a id="X81DDD2E87F68E086" name="X81DDD2E87F68E086"></a></p>
176
177 <h5>9.4-5 ChangeDirectoryCurrent</h5>
178
179 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ChangeDirectoryCurrent</code>( <var class="Arg">path</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
180 <p>Changes the current directory. Returns <code class="keyw">true</code> on success and <code class="keyw">fail</code> on failure.</p>
181
182 <p><a id="X87ED469A85343A3C" name="X87ED469A85343A3C"></a></p>
183
184 <h5>9.4-6 DirectoriesLibrary</h5>
185
186 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoriesLibrary</code>( [<var class="Arg">name</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
187 <p><code class="func">DirectoriesLibrary</code> returns the directory objects for the <strong class="pkg">GAP</strong> library <var class="Arg">name</var> as a list. <var class="Arg">name</var> must be one of <code class="code">"lib"</code> (the default), <code class="code">"doc"</code>, <code class="code">"tst"</code>, and so on.</p>
188
189 <p>The string <code class="code">""</code> is also legal and with this argument <code class="func">DirectoriesLibrary</code> returns the list of <strong class="pkg">GAP</strong> root directories. The return value of this call differs from <code class="code">GAPInfo.RootPaths</code> in that the former is a list of directory objects and the latter a list of strings.</p>
190
191 <p>The directory <var class="Arg">name</var> must exist in at least one of the root directories, otherwise <code class="keyw">fail</code> is returned.</p>
192
193 <p>As the files in the <strong class="pkg">GAP</strong> root directories (see <a href="chap9.html#X7A4973627A5DB27D"><span class="RefLink">9.2</span></a>) can be distributed into different directories in the filespace a list of directories is returned. In order to find an existing file in a <strong class="pkg">GAP</strong> root directory you should pass that list to <code class="func">Filename</code> (<a href="chap9.html#X7E352E1F87060602"><span class="RefLink">9.5-1</span></a>) as the first argument. In order to create a filename for a new file inside a <strong class="pkg">GAP</strong> root directory you should pass the first entry of that list. However, creating files inside the <strong class="pkg">GAP</strong> root directory is not recommended, you should use <code class="func">DirectoryTemporary</code> (<a href="chap9.html#X8222B1A886E6195E"><span class="RefLink">9.4-3</span></a>) instead.</p>
194
195 <p><a id="X808E2C187DD984B4" name="X808E2C187DD984B4"></a></p>
196
197 <h5>9.4-7 DirectoriesSystemPrograms</h5>
198
199 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoriesSystemPrograms</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
200 <p><code class="func">DirectoriesSystemPrograms</code> returns the directory objects for the list of directories where the system programs reside, as a list. Under UNIX this would usually represent <code class="code">$PATH</code>.</p>
201
202 <p><a id="X7B225E5282534EDA" name="X7B225E5282534EDA"></a></p>
203
204 <h5>9.4-8 DirectoryContents</h5>
205
206 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryContents</code>( <var class="Arg">dir</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
207 <p>This function returns a list of filenames/directory names that reside in the directory <var class="Arg">dir</var>. The argument <var class="Arg">dir</var> can either be given as a string indicating the name of the directory or as a directory object (see <code class="func">IsDirectory</code> (<a href="chap9.html#X82B3E24683942597"><span class="RefLink">9.4-1</span></a>)). If an error occurs (the specified directory does not exist or has no read permissions), <code class="keyw">fail</code> is returned. In this case <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>
208
209 <p>The ordering of the list entries can depend on the operating system.</p>
210
211 <p>An interactive way to show the contents of a directory is provided by the function <code class="func">BrowseDirectory</code> (<a href="../../pkg/browse/doc/chap6.html#X859682DE8397261E"><span class="RefLink">Browse: BrowseDirectory</span></a>) from the <strong class="pkg">GAP</strong> package <strong class="pkg">Browse</strong>.</p>
212
213 <p><a id="X86F4A32C83B82369" name="X86F4A32C83B82369"></a></p>
214
215 <h5>9.4-9 DirectoryDesktop</h5>
216
217 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryDesktop</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
218 <p>returns a directory object for the user's desktop directory as defined on many modern operating systems. The function is intended to provide a cross-platform interface to a directory that is easily accessible by the user.</p>
219
220 <p>Under Unix systems (including macOS) this will be the <code class="code">Desktop</code> directory in the user's home directory if it exists, and the user's home directory otherwise. Under Windows it will be the user's <code class="code">Desktop</code> folder (or the appropriate name under different languages).</p>
221
222 <p><a id="X7B0D818A808A3481" name="X7B0D818A808A3481"></a></p>
223
224 <h5>9.4-10 DirectoryHome</h5>
225
226 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DirectoryHome</code>( )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
227 <p>returns a directory object for the user's home directory, defined as a directory in which the user will typically have full read and write access. The function is intended to provide a cross-platform interface to a directory that is easily accessible by the user.</p>
228
229 <p>Under Unix systems (including macOS) this will be the usual user home directory. Under Windows it will be the user's <code class="code">My Documents</code> folder (or the appropriate name under different languages).</p>
230
231 <p><a id="X8545E03E7D651456" name="X8545E03E7D651456"></a></p>
232
233 <h4>9.5 <span class="Heading">File Names</span></h4>
234
235 <p><a id="X7E352E1F87060602" name="X7E352E1F87060602"></a></p>
236
237 <h5>9.5-1 <span class="Heading">Filename</span></h5>
238
239 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Filename</code>( <var class="Arg">dir</var>, <var class="Arg">name</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
240 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Filename</code>( <var class="Arg">list-of-dirs</var>, <var class="Arg">name</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
241 <p>If the first argument is a directory object <var class="Arg">dir</var>, <code class="func">Filename</code> returns the (system dependent) filename as a string for the file with name <var class="Arg">name</var> in the directory <var class="Arg">dir</var>. <code class="func">Filename</code> returns the filename regardless of whether the directory contains a file with name <var class="Arg">name</var> or not.</p>
242
243 <p>If the first argument is a list <var class="Arg">list-of-dirs</var> (possibly of length 1) of directory objects, then <code class="func">Filename</code> searches the directories in order, and returns the filename for the file <var class="Arg">name</var> in the first directory which contains a file <var class="Arg">name</var> or <code class="keyw">fail</code> if no directory contains a file <var class="Arg">name</var>.</p>
244
245 <p><em>For example</em>, in order to locate the system program <code class="code">date</code> use <code class="func">PathSystemProgram</code> (<a href="chap9.html#X86C7683E7A2A2146"><span class="RefLink">9.5-2</span></a>).</p>
246
247
248 <div class="example"><pre>
249 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">date := PathSystemProgram( "date" );</span>
250 "/bin/date"
251 </pre></div>
252
253 <p>In order to locate the library file <code class="file">files.gd</code> use <code class="func">DirectoriesLibrary</code> (<a href="chap9.html#X87ED469A85343A3C"><span class="RefLink">9.4-6</span></a>) together with the second form of <code class="func">Filename</code>.</p>
254
255
256 <div class="example"><pre>
257 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">path := DirectoriesLibrary();;</span>
258 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( path, "files.gd" );</span>
259 "./lib/files.gd"
260 </pre></div>
261
262 <p>In order to construct filenames for new files in a temporary directory use <code class="func">DirectoryTemporary</code> (<a href="chap9.html#X8222B1A886E6195E"><span class="RefLink">9.4-3</span></a>) together with the first form of <code class="func">Filename</code>.</p>
263
264
265 <div class="example"><pre>
266 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">tmpdir := DirectoryTemporary();;</span>
267 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( [ tmpdir ], "file.new" );</span>
268 fail
269 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Filename( tmpdir, "file.new" );</span>
270 "/var/tmp/tmp.0.021738.0001/file.new"
271 </pre></div>
272
273 <p><a id="X86C7683E7A2A2146" name="X86C7683E7A2A2146"></a></p>
274
275 <h5>9.5-2 PathSystemProgram</h5>
276
277 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PathSystemProgram</code>( <var class="Arg">name</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
278 <p><code class="func">PathSystemProgram</code> returns either the path of the first executable file <var class="Arg">name</var> in one of the directories returned by <code class="func">DirectoriesSystemPrograms</code> (<a href="chap9.html#X808E2C187DD984B4"><span class="RefLink">9.4-7</span></a>), or <code class="keyw">fail</code> if no such file exists.</p>
279
280 <p><a id="X85EC7D9087C481B0" name="X85EC7D9087C481B0"></a></p>
281
282 <h4>9.6 <span class="Heading">Special Filenames</span></h4>
283
284 <p>The special filename <code class="code">"*stdin*"</code> denotes the standard input, i.e., the stream through which the user enters commands to <strong class="pkg">GAP</strong>. The exact behaviour of reading from <code class="code">"*stdin*"</code> is operating system dependent, but usually the following happens. If <strong class="pkg">GAP</strong> was started with no input redirection, statements are read from the terminal stream until the user enters the end of file character, which is usually <strong class="button">Ctrl-D</strong>. Note that terminal streams are special, in that they may yield ordinary input <em>after</em> an end of file. Thus when control returns to the main read-eval-print loop the user can continue with <strong class="pkg">GAP</strong>. If <strong class="pkg">GAP</strong> was started with an input redirection, statements are read from the current position in the input file up to the end of the file. When control returns to the main read eval view loop the input stream will still return end of file, and <strong class="pkg">GAP</strong> will terminate.</p>
285
286 <p>The special filename <code class="code">"*errin*"</code> denotes the stream connected to the UNIX <code class="code">stderr</code> output. This stream is usually connected to the terminal, even if the standard input was redirected, unless the standard error stream was also redirected, in which case opening of <code class="code">"*errin*"</code> fails.</p>
287
288 <p>The special filename <code class="code">"*stdout*"</code> can be used to print to the standard output.</p>
289
290 <p>The special filename <code class="code">"*errout*"</code> can be used to print to the standard error output file, which is usually connected to the terminal, even if the standard output was redirected.</p>
291
292 <p><a id="X87271FEF86A6A0F9" name="X87271FEF86A6A0F9"></a></p>
293
294 <h4>9.7 <span class="Heading">File Access</span></h4>
295
296 <p>When the following functions return <code class="keyw">false</code> one can use <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) to find out the reason (as provided by the operating system), see the examples.</p>
297
298 <p><a id="X8269697A7B927AF1" name="X8269697A7B927AF1"></a></p>
299
300 <h5>9.7-1 IsExistingFile</h5>
301
302 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsExistingFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
303 <p><code class="func">IsExistingFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists and can be seen by the <strong class="pkg">GAP</strong> process. Otherwise <code class="keyw">false</code> is returned.</p>
304
305
306 <div class="example"><pre>
307 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date" ); # file `/bin/date' exists</span>
308 true
309 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date.new" ); # non existing `/bin/date.new'</span>
310 false
311 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExistingFile( "/bin/date/new" ); # `/bin/date' is not a directory</span>
312 false
313 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LastSystemError().message;</span>
314 "Not a directory"
315 </pre></div>
316
317 <p><a id="X7E156EC886E11BBC" name="X7E156EC886E11BBC"></a></p>
318
319 <h5>9.7-2 IsReadableFile</h5>
320
321 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsReadableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
322 <p><code class="func">IsReadableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has read permissions for the file, or <code class="keyw">false</code> if this is not the case.</p>
323
324
325 <div class="example"><pre>
326 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsReadableFile( "/bin/date" ); # file `/bin/date' is readable</span>
327 true
328 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsReadableFile( "/bin/date.new" ); # non-existing `/bin/date.new'</span>
329 false
330 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LastSystemError().message;</span>
331 "No such file or directory"
332 </pre></div>
333
334 <p><a id="X8412F485796B25F5" name="X8412F485796B25F5"></a></p>
335
336 <h5>9.7-3 IsWritableFile</h5>
337
338 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWritableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
339 <p><code class="func">IsWritableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has write permissions for the file, or <code class="keyw">false</code> if this is not the case.</p>
340
341
342 <div class="example"><pre>
343 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWritableFile( "/bin/date" ); # file `/bin/date' is not writable</span>
344 false
345 </pre></div>
346
347 <p><a id="X83A1AAD58435FC4C" name="X83A1AAD58435FC4C"></a></p>
348
349 <h5>9.7-4 IsExecutableFile</h5>
350
351 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsExecutableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
352 <p><code class="func">IsExecutableFile</code> returns <code class="keyw">true</code> if a file with the filename <var class="Arg">filename</var> exists <em>and</em> the <strong class="pkg">GAP</strong> process has execute permissions for the file, or <code class="keyw">false</code> if this is not the case. Note that execute permissions do not imply that it is possible to execute the file, e.g., it may only be executable on a different machine.</p>
353
354
355 <div class="example"><pre>
356 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsExecutableFile( "/bin/date" ); # ... but executable</span>
357 true
358 </pre></div>
359
360 <p><a id="X7D1BE00F83C4EEE8" name="X7D1BE00F83C4EEE8"></a></p>
361
362 <h5>9.7-5 IsDirectoryPath</h5>
363
364 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsDirectoryPath</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
365 <p><code class="func">IsDirectoryPath</code> returns <code class="keyw">true</code> if the file with the filename <var class="Arg">filename</var> exists <em>and</em> is a directory, and <code class="keyw">false</code> otherwise. Note that this function does not check if the <strong class="pkg">GAP</strong> process actually has write or execute permissions for the directory. You can use <code class="func">IsWritableFile</code> (<a href="chap9.html#X8412F485796B25F5"><span class="RefLink">9.7-3</span></a>), resp. <code class="func">IsExecutableFile</code> (<a href="chap9.html#X83A1AAD58435FC4C"><span class="RefLink">9.7-4</span></a>) to check such permissions.</p>
366
367 <p><a id="X81A0A4FF842B039B" name="X81A0A4FF842B039B"></a></p>
368
369 <h4>9.8 <span class="Heading">File Operations</span></h4>
370
371 <p><a id="X8373AC6B7D5F9167" name="X8373AC6B7D5F9167"></a></p>
372
373 <h5>9.8-1 Read</h5>
374
375 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Read</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
376 <p>reads the input from the file with the filename <var class="Arg">filename</var>, which must be given as a string.</p>
377
378 <p><code class="func">Read</code> first opens the file <var class="Arg">filename</var>. If the file does not exist, or if <strong class="pkg">GAP</strong> cannot open it, e.g., because of access restrictions, an error is signalled.</p>
379
380 <p>Then the contents of the file are read and evaluated, but the results are not printed. The reading and evaluations happens exactly as described for the main loop (see <a href="chap6.html#X81667F568237B232"><span class="RefLink">6.1</span></a>).</p>
381
382 <p>If a statement in the file causes an error a break loop is entered (see <a href="chap6.html#X8593B49F8705B486"><span class="RefLink">6.4</span></a>). The input for this break loop is not taken from the file, but from the input connected to the <code class="code">stderr</code> output of <strong class="pkg">GAP</strong>. If <code class="code">stderr</code> is not connected to a terminal, no break loop is entered. If this break loop is left with <code class="keyw">quit</code> (or <strong class="button">Ctrl-D</strong>), <strong class="pkg">GAP</strong> exits from the <code class="func">Read</code> command, and from all enclosing <code class="func">Read</code> commands, so that control is normally returned to an interactive prompt. The <code class="keyw">QUIT</code> statement (see <a href="chap6.html#X83704B1080FD9B40"><span class="RefLink">6.7</span></a>) can also be used in the break loop to exit <strong class="pkg">GAP</strong> immediately.</p>
383
384 <p>Note that a statement must not begin in one file and end in another. I.e., <em>eof</em> (<em>e</em>nd-<em>o</em>f-<em>f</em>ile) is not treated as whitespace, but as a special symbol that must not appear inside any statement.</p>
385
386 <p>Note that one file may very well contain a read statement causing another file to be read, before input is again taken from the first file. There is an upper limit of 15 on the number of files that may be open simultaneously.</p>
387
388 <p><a id="X7824CB7D7D4BAFBC" name="X7824CB7D7D4BAFBC"></a></p>
389
390 <h5>9.8-2 ReadAsFunction</h5>
391
392 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReadAsFunction</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
393 <p>reads the file with filename <var class="Arg">filename</var> as a function and returns this function.</p>
394
395 <p><em>Example</em></p>
396
397 <p>Suppose that the file <code class="file">/tmp/example.g</code> contains the following</p>
398
399
400 <div class="example"><pre>
401 local a;
402
403 a := 10;
404 return a*10;
405 </pre></div>
406
407 <p>Reading the file as a function will not affect a global variable <code class="code">a</code>.</p>
408
409
410 <div class="example"><pre>
411 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a := 1;</span>
412 1
413 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ReadAsFunction("/tmp/example.g")();</span>
414 100
415 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a;</span>
416 1
417 </pre></div>
418
419 <p><a id="X86956C577FFEE1F9" name="X86956C577FFEE1F9"></a></p>
420
421 <h5>9.8-3 <span class="Heading">PrintTo and AppendTo</span></h5>
422
423 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PrintTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
424 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AppendTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
425 <p><code class="func">PrintTo</code> works like <code class="func">Print</code> (<a href="chap6.html#X7AFA64D97A1F39A3"><span class="RefLink">6.3-4</span></a>), except that the arguments <var class="Arg">obj1</var>, <span class="SimpleMath">...</span> (if present) are printed to the file with the name <var class="Arg">filename</var> instead of the standard output. This file must of course be writable by <strong class="pkg">GAP</strong>. Otherwise an error is signalled. Note that <code class="func">PrintTo</code> will <em>overwrite</em> the previous contents of this file if it already existed; in particular, <code class="func">PrintTo</code> with just the <var class="Arg">filename</var> argument empties that file.</p>
426
427 <p><code class="func">AppendTo</code> works like <code class="func">PrintTo</code>, except that the output does not overwrite the previous contents of the file, but is appended to the file.</p>
428
429 <p>There is an upper limit of 15 on the number of output files that may be open simultaneously.</p>
430
431 <p><em>Note</em> that one should be careful not to write to a logfile (see <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.8-4</span></a>)) with <code class="func">PrintTo</code> or <code class="func">AppendTo</code>.</p>
432
433 <p><a id="X79813A6686894960" name="X79813A6686894960"></a></p>
434
435 <h5>9.8-4 <span class="Heading">LogTo</span></h5>
436
437 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
438 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; LogTo</code>( )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
439 <p>Calling <code class="func">LogTo</code> with a string <var class="Arg">filename</var> causes the subsequent interaction to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything you see on your terminal will also appear in this file. (<code class="func">LogTo</code> (<a href="chap10.html#X7BF4E44C7D51E085"><span class="RefLink">10.4-5</span></a>) may also be used to log to a stream.) This file must of course be writable by <strong class="pkg">GAP</strong>, otherwise an error is signalled. Note that <code class="func">LogTo</code> will overwrite the previous contents of this file if it already existed.</p>
440
441 <p>Called without arguments, <code class="func">LogTo</code> stops logging to a file or stream.</p>
442
443 <p><a id="X7CAB119378B075B7" name="X7CAB119378B075B7"></a></p>
444
445 <h5>9.8-5 <span class="Heading">InputLogTo</span></h5>
446
447 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
448 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InputLogTo</code>( )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
449 <p>Calling <code class="func">InputLogTo</code> with a string <var class="Arg">filename</var> causes the subsequent input to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything you type on your terminal will also appear in this file. Note that <code class="func">InputLogTo</code> and <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.8-4</span></a>) cannot be used at the same time while <code class="func">InputLogTo</code> and <code class="func">OutputLogTo</code> (<a href="chap9.html#X7A5591D87EAFA6CC"><span class="RefLink">9.8-6</span></a>) can. Note that <code class="func">InputLogTo</code> will overwrite the previous contents of this file if it already existed.</p>
450
451 <p>Called without arguments, <code class="func">InputLogTo</code> stops logging to a file or stream.</p>
452
453 <p><a id="X7A5591D87EAFA6CC" name="X7A5591D87EAFA6CC"></a></p>
454
455 <h5>9.8-6 <span class="Heading">OutputLogTo</span></h5>
456
457 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OutputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
458 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OutputLogTo</code>( )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
459 <p>Calling <code class="func">OutputLogTo</code> with a string <var class="Arg">filename</var> causes the subsequent output to be logged to the file with the name <var class="Arg">filename</var>, i.e., everything <strong class="pkg">GAP</strong> prints on your terminal will also appear in this file. Note that <code class="func">OutputLogTo</code> and <code class="func">LogTo</code> (<a href="chap9.html#X79813A6686894960"><span class="RefLink">9.8-4</span></a>) cannot be used at the same time while <code class="func">InputLogTo</code> (<a href="chap9.html#X7CAB119378B075B7"><span class="RefLink">9.8-5</span></a>) and <code class="func">OutputLogTo</code> can. Note that <code class="func">OutputLogTo</code> will overwrite the previous contents of this file if it already existed.</p>
460
461 <p>Called without arguments, <code class="func">OutputLogTo</code> stops logging to a file or stream.</p>
462
463 <p><a id="X8241CEAD80415BB9" name="X8241CEAD80415BB9"></a></p>
464
465 <h5>9.8-7 CrcFile</h5>
466
467 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CrcFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
468 <p>This function computes a CRC (cyclic redundancy check) number for the content of the file <var class="Arg">filename</var>.</p>
469
470 <p><code class="func">CrcFile</code> computes a CRC (cyclic redundancy check) checksum value for the file with filename <var class="Arg">filename</var> and returns this value as an integer. The function returns <code class="keyw">fail</code> if an error occurred, for example, if <var class="Arg">filename</var> does not exist. In this case the function <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error. See also <code class="func">CrcFile</code> and <code class="func">HexSHA256</code> (<a href="chap27.html#X7873D1F28779B490"><span class="RefLink">27.9-7</span></a>).</p>
471
472
473 <div class="example"><pre>
474 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CrcFile( "lib/morpheus.gi" );</span>
475 2705743645
476 </pre></div>
477
478 <p><a id="X7E63ACA38142BE96" name="X7E63ACA38142BE96"></a></p>
479
480 <h5>9.8-8 RemoveFile</h5>
481
482 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; RemoveFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
483 <p>will remove the file with filename <var class="Arg">filename</var> and returns <code class="keyw">true</code> in case of success. The function returns <code class="keyw">fail</code> if a system error occurred, for example, if your permissions do not allow the removal of <var class="Arg">filename</var>. In this case the function <code class="func">LastSystemError</code> (<a href="chap9.html#X87D278437A916905"><span class="RefLink">9.1-1</span></a>) can be used to get information about the error.</p>
484
485 <p><a id="X83F3B0337C7EA5CC" name="X83F3B0337C7EA5CC"></a></p>
486
487 <h5>9.8-9 UserHomeExpand</h5>
488
489 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; UserHomeExpand</code>( <var class="Arg">str</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
490 <p>If the string <var class="Arg">str</var> starts with a <code class="code">'~'</code> character this function returns a new string with the leading <code class="code">'~'</code> substituted by the user's home directory as stored in <code class="code">GAPInfo.UserHome</code>. Otherwise <var class="Arg">str</var> is returned unchanged.</p>
491
492 <p>This function is the counterpart of <code class="func">UserHomeShorten</code> (<a href="chap9.html#X7B450DAD8651FC2B"><span class="RefLink">9.8-10</span></a>).</p>
493
494 <p><a id="X7B450DAD8651FC2B" name="X7B450DAD8651FC2B"></a></p>
495
496 <h5>9.8-10 UserHomeShorten</h5>
497
498 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; UserHomeShorten</code>( <var class="Arg">str</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
499 <p>If the string <var class="Arg">str</var> starts with the user's home directory as stored in <code class="code">GAPInfo.UserHome</code> then this function returns a new string with that prefix replaced by a leading <code class="code">'~'</code> character. Otherwise <var class="Arg">str</var> is returned unchanged.</p>
500
501 <p>This function is the counterpart of <code class="func">UserHomeExpand</code> (<a href="chap9.html#X83F3B0337C7EA5CC"><span class="RefLink">9.8-9</span></a>).</p>
502
503 <p><a id="X79EE267A7FAF28A6" name="X79EE267A7FAF28A6"></a></p>
504
505 <h5>9.8-11 Reread</h5>
506
507 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Reread</code>( <var class="Arg">filename</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
508 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; REREADING</code></td><td class="tdright">(&nbsp;global variable&nbsp;)</td></tr></table></div>
509 <p>In general, it is not possible to read the same <strong class="pkg">GAP</strong> library file twice, or to read a compiled version after reading a <strong class="pkg">GAP</strong> version, because crucial global variables are made read-only (see <a href="chap4.html#X816FBEEA85782EC2"><span class="RefLink">4.9</span></a>) and filters and methods are added to global tables.</p>
510
511 <p>A partial solution to this problem is provided by the function <code class="func">Reread</code> (and related functions <code class="code">RereadLib</code> etc.). <code class="code">Reread( <var class="Arg">filename</var> )</code> sets the global variable <code class="func">REREADING</code> to <code class="keyw">true</code>, reads the file named by <var class="Arg">filename</var> and then resets <code class="func">REREADING</code>. Various system functions behave differently when <code class="func">REREADING</code> is set to <code class="keyw">true</code>. In particular, assignment to read-only global variables is permitted, calls to <code class="func">NewRepresentation</code> (<a href="chap13.html#X7CC8106F809E15CF"><span class="RefLink">13.4-4</span></a>) and <code class="func">NewInfoClass</code> (<a href="chap7.html#X7AA1A1CF79F20790"><span class="RefLink">7.4-1</span></a>) with parameters identical to those of an existing representation or info class will return the existing object, and methods installed with <code class="func">InstallMethod</code> (<a href="chap78.html#X837EFDAB7BEF290B"><span class="RefLink">78.3-1</span></a>) may sometimes displace existing methods.</p>
512
513 <p>This function may not entirely produce the intended results, especially if what has changed is the super-representation of a representation or the requirements of a method. In these cases, it is necessary to restart <strong class="pkg">GAP</strong> to read the modified file.</p>
514
515 <p>An additional use of <code class="func">Reread</code> is to load the compiled version of a file for which the <strong class="pkg">GAP</strong> language version had previously been read (or perhaps was included in a saved workspace). See <a href="chap76.html#X85672DDD7D34D5F0"><span class="RefLink">76.3-11</span></a> and <a href="chap3.html#X7CB282757ACB1C09"><span class="RefLink">3.3</span></a> for more information.</p>
516
517 <p>It is not advisable to use <code class="func">Reread</code> programmatically. For example, if a file that contains calls to <code class="func">Reread</code> is read with <code class="func">Reread</code> then <code class="func">REREADING</code> may be reset too early.</p>
518
519
520 <div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap8.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap10.html">[Next Chapter]</a>&nbsp; </div>
521
522
523 <div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a> <a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chap6.html">6</a> <a href="chap7.html">7</a> <a href="chap8.html">8</a> <a href="chap9.html">9</a> <a href="chap10.html">10</a> <a href="chap11.html">11</a> <a href="chap12.html">12</a> <a href="chap13.html">13</a> <a href="chap14.html">14</a> <a href="chap15.html">15</a> <a href="chap16.html">16</a> <a href="chap17.html">17</a> <a href="chap18.html">18</a> <a href="chap19.html">19</a> <a href="chap20.html">20</a> <a href="chap21.html">21</a> <a href="chap22.html">22</a> <a href="chap23.html">23</a> <a href="chap24.html">24</a> <a href="chap25.html">25</a> <a href="chap26.html">26</a> <a href="chap27.html">27</a> <a href="chap28.html">28</a> <a href="chap29.html">29</a> <a href="chap30.html">30</a> <a href="chap31.html">31</a> <a href="chap32.html">32</a> <a href="chap33.html">33</a> <a href="chap34.html">34</a> <a href="chap35.html">35</a> <a href="chap36.html">36</a> <a href="chap37.html">37</a> <a href="chap38.html">38</a> <a href="chap39.html">39</a> <a href="chap40.html">40</a> <a href="chap41.html">41</a> <a href="chap42.html">42</a> <a href="chap43.html">43</a> <a href="chap44.html">44</a> <a href="chap45.html">45</a> <a href="chap46.html">46</a> <a href="chap47.html">47</a> <a href="chap48.html">48</a> <a href="chap49.html">49</a> <a href="chap50.html">50</a> <a href="chap51.html">51</a> <a href="chap52.html">52</a> <a href="chap53.html">53</a> <a href="chap54.html">54</a> <a href="chap55.html">55</a> <a href="chap56.html">56</a> <a href="chap57.html">57</a> <a href="chap58.html">58</a> <a href="chap59.html">59</a> <a href="chap60.html">60</a> <a href="chap61.html">61</a> <a href="chap62.html">62</a> <a href="chap63.html">63</a> <a href="chap64.html">64</a> <a href="chap65.html">65</a> <a href="chap66.html">66</a> <a href="chap67.html">67</a> <a href="chap68.html">68</a> <a href="chap69.html">69</a> <a href="chap70.html">70</a> <a href="chap71.html">71</a> <a href="chap72.html">72</a> <a href="chap73.html">73</a> <a href="chap74.html">74</a> <a href="chap75.html">75</a> <a href="chap76.html">76</a> <a href="chap77.html">77</a> <a href="chap78.html">78</a> <a href="chap79.html">79</a> <a href="chap80.html">80</a> <a href="chap81.html">81</a> <a href="chap82.html">82</a> <a href="chap83.html">83</a> <a href="chap84.html">84</a> <a href="chap85.html">85</a> <a href="chap86.html">86</a> <a href="chap87.html">87</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
524
525 <hr />
526 <p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
527 </body>
528 </html>