Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/GAP/doc/ref/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 54 kB image not shown  

Quelle  chap9.html   Sprache: HTML

 
 products/sources/formale Sprachen/GAP/doc/ref/chap9.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 9: Files and Filenames</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap9"  onload="jscontent()">


<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>

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap8.html">[Previous Chapter]</a>    <a href="chap10.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap9_mj.html">[MathJax on]</a></p>
<p><a id="X82BCD4297920C903" name="X82BCD4297920C903"></a></p>
<div class="ChapSects"><a href="chap9.html#X82BCD4297920C903">9 <span class="Heading">Files and Filenames</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X83D8AAA484EE95D9">9.1 <span class="Heading">Portability</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X87D278437A916905">9.1-1 LastSystemError</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X7A4973627A5DB27D">9.2 <span class="Heading">GAP Root Directories</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X8223D52E78AF4420">9.3 <span class="Heading">GAP Package Directories</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X85030B35865A1080">9.4 <span class="Heading">Directories</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X82B3E24683942597">9.4-1 IsDirectory</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X86A71E927EEC7EAD">9.4-2 Directory</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8222B1A886E6195E">9.4-3 DirectoryTemporary</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7BAD8036849E8430">9.4-4 DirectoryCurrent</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X81DDD2E87F68E086">9.4-5 ChangeDirectoryCurrent</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X87ED469A85343A3C">9.4-6 DirectoriesLibrary</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X808E2C187DD984B4">9.4-7 DirectoriesSystemPrograms</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7B225E5282534EDA">9.4-8 DirectoryContents</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X86F4A32C83B82369">9.4-9 DirectoryDesktop</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7B0D818A808A3481">9.4-10 DirectoryHome</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X8545E03E7D651456">9.5 <span class="Heading">File Names</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7E352E1F87060602">9.5-1 <span class="Heading">Filename</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X86C7683E7A2A2146">9.5-2 PathSystemProgram</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X85EC7D9087C481B0">9.6 <span class="Heading">Special Filenames</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X87271FEF86A6A0F9">9.7 <span class="Heading">File Access</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8269697A7B927AF1">9.7-1 IsExistingFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7E156EC886E11BBC">9.7-2 IsReadableFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8412F485796B25F5">9.7-3 IsWritableFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X83A1AAD58435FC4C">9.7-4 IsExecutableFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7D1BE00F83C4EEE8">9.7-5 IsDirectoryPath</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap9.html#X81A0A4FF842B039B">9.8 <span class="Heading">File Operations</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8373AC6B7D5F9167">9.8-1 Read</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7824CB7D7D4BAFBC">9.8-2 ReadAsFunction</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X86956C577FFEE1F9">9.8-3 <span class="Heading">PrintTo and AppendTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X79813A6686894960">9.8-4 <span class="Heading">LogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7CAB119378B075B7">9.8-5 <span class="Heading">InputLogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7A5591D87EAFA6CC">9.8-6 <span class="Heading">OutputLogTo</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X8241CEAD80415BB9">9.8-7 CrcFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X7E63ACA38142BE96">9.8-8 RemoveFile</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X83F3B0337C7EA5CC">9.8-9 UserHomeExpand</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap9.html#X79EE267A7FAF28A6">9.8-10 Reread</a></span>
</div></div>
</div>

<h3>9 <span class="Heading">Files and Filenames</span></h3>

<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>

<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>

<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>

<p><a id="X83D8AAA484EE95D9" name="X83D8AAA484EE95D9"></a></p>

<h4>9.1 <span class="Heading">Portability</span></h4>

<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>

<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>

<p><a id="X87D278437A916905" name="X87D278437A916905"></a></p>

<h5>9.1-1 LastSystemError</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LastSystemError</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><a id="X7A4973627A5DB27D" name="X7A4973627A5DB27D"></a></p>

<h4>9.2 <span class="Heading">GAP Root Directories</span></h4>

<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>

<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>

<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>

<p>The root directories are specified via one or several of the <code class="code">-l paths</codecommand 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</codeoption. 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>

<p><a id="X8223D52E78AF4420" name="X8223D52E78AF4420"></a></p>

<h4>9.3 <span class="Heading">GAP Package Directories</span></h4>

<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>

<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</codecommand 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>

<p><strong class="pkg">GAP</strong> looks for available packages by examining each of the directories in <code class="code">GAPInfo.PackageDirectories</code>.</p>

<p><a id="X85030B35865A1080" name="X85030B35865A1080"></a></p>

<h4>9.4 <span class="Heading">Directories</span></h4>

<p><a id="X82B3E24683942597" name="X82B3E24683942597"></a></p>

<h5>9.4-1 IsDirectory</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsDirectory</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p><code class="func">IsDirectory</code> is a category of directories.</p>

<p><a id="X86A71E927EEC7EAD" name="X86A71E927EEC7EAD"></a></p>

<h5>9.4-2 Directory</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Directory</code>( <var class="Arg">string</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<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>

<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 "~other_user" is not interpreted as a path relative to other_user's home directory, as in a UNIX shell).</p>

<p>Paths are otherwise taken relative to the current directory.</p>

<p><a id="X8222B1A886E6195E" name="X8222B1A886E6195E"></a></p>

<h5>9.4-3 DirectoryTemporary</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoryTemporary</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<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>

<p>A warning message is given if more than 1000 temporary directories are created in any <strong class="pkg">GAP</strong> session.</p>

<p><a id="X7BAD8036849E8430" name="X7BAD8036849E8430"></a></p>

<h5>9.4-4 DirectoryCurrent</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoryCurrent</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<p>returns the directory object for the current directory.</p>

<p><a id="X81DDD2E87F68E086" name="X81DDD2E87F68E086"></a></p>

<h5>9.4-5 ChangeDirectoryCurrent</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ChangeDirectoryCurrent</code>( <var class="Arg">path</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Changes the current directory. Returns <code class="keyw">true</code> on success and <code class="keyw">fail</code> on failure.</p>

<p><a id="X87ED469A85343A3C" name="X87ED469A85343A3C"></a></p>

<h5>9.4-6 DirectoriesLibrary</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoriesLibrary</code>( [<var class="Arg">name</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<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>

<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>

<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>

<p><a id="X808E2C187DD984B4" name="X808E2C187DD984B4"></a></p>

<h5>9.4-7 DirectoriesSystemPrograms</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoriesSystemPrograms</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><a id="X7B225E5282534EDA" name="X7B225E5282534EDA"></a></p>

<h5>9.4-8 DirectoryContents</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoryContents</code>( <var class="Arg">dir</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p>The ordering of the list entries can depend on the operating system.</p>

<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>

<p><a id="X86F4A32C83B82369" name="X86F4A32C83B82369"></a></p>

<h5>9.4-9 DirectoryDesktop</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoryDesktop</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<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>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 Desktop folder (or the appropriate name under different languages).



<p><a id="X7B0D818A808A3481" name="X7B0D818A808A3481"></a></p>

<h5>9.4-10 DirectoryHome</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DirectoryHome</code>(  )</td><td class="tdright">( function )</td></tr></table></div>
<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>Under Unix systems (including macOS) this will be the usual user home directory. Under Windows it will be the user's My Documents folder (or the appropriate name under different languages).



<p><a id="X8545E03E7D651456" name="X8545E03E7D651456"></a></p>

<h4>9.5 <span class="Heading">File Names</span></h4>

<p><a id="X7E352E1F87060602" name="X7E352E1F87060602"></a></p>

<h5>9.5-1 <span class="Heading">Filename</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Filename</code>( <var class="Arg">dir</var>, <var class="Arg">name</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Filename</code>( <var class="Arg">list-of-dirs</var>, <var class="Arg">name</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<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>

<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>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">date := PathSystemProgram( "date" );</span>
"/bin/date"
</pre></div>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">path := DirectoriesLibrary();;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Filename( path, "files.gd" );</span>
"./lib/files.gd"
</pre></div>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">tmpdir := DirectoryTemporary();;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">Filename( [ tmpdir ], "file.new" );</span>
fail
<span class="GAPprompt">gap></span> <span class="GAPinput">Filename( tmpdir, "file.new" );</span>
"/var/tmp/tmp.0.021738.0001/file.new"
</pre></div>

<p><a id="X86C7683E7A2A2146" name="X86C7683E7A2A2146"></a></p>

<h5>9.5-2 PathSystemProgram</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PathSystemProgram</code>( <var class="Arg">name</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><a id="X85EC7D9087C481B0" name="X85EC7D9087C481B0"></a></p>

<h4>9.6 <span class="Heading">Special Filenames</span></h4>

<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>

<p>The special filename <code class="code">"*errin*"</code> denotes the stream connected to the UNIX <code class="code">stderr</codeoutput. 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>

<p>The special filename <code class="code">"*stdout*"</code> can be used to print to the standard output.</p>

<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>

<p><a id="X87271FEF86A6A0F9" name="X87271FEF86A6A0F9"></a></p>

<h4>9.7 <span class="Heading">File Access</span></h4>

<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>

<p><a id="X8269697A7B927AF1" name="X8269697A7B927AF1"></a></p>

<h5>9.7-1 IsExistingFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsExistingFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsExistingFile( "/bin/date" );     # file `/bin/date' exists

true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsExistingFile( "/bin/date.new" ); # non existing `/bin/date.new'
false
<span class="GAPprompt">gap></span> <span class="GAPinput">IsExistingFile( "/bin/date/new" ); # `/bin/date' is not a directory
false
<span class="GAPprompt">gap></span> <span class="GAPinput">LastSystemError().message;</span>
"Not a directory"
</pre></div>

<p><a id="X7E156EC886E11BBC" name="X7E156EC886E11BBC"></a></p>

<h5>9.7-2 IsReadableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsReadableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsReadableFile( "/bin/date" );     # file `/bin/date' is readable
true
<span class="GAPprompt">gap></span> <span class="GAPinput">IsReadableFile( "/bin/date.new" ); # non-existing `/bin/date.new'
false
<span class="GAPprompt">gap></span> <span class="GAPinput">LastSystemError().message;</span>
"No such file or directory"
</pre></div>

<p><a id="X8412F485796B25F5" name="X8412F485796B25F5"></a></p>

<h5>9.7-3 IsWritableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsWritableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsWritableFile( "/bin/date" );  # file `/bin/date' is not writable
false
</pre></div>

<p><a id="X83A1AAD58435FC4C" name="X83A1AAD58435FC4C"></a></p>

<h5>9.7-4 IsExecutableFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsExecutableFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">IsExecutableFile( "/bin/date" );   # ... but executable</span>
true
</pre></div>

<p><a id="X7D1BE00F83C4EEE8" name="X7D1BE00F83C4EEE8"></a></p>

<h5>9.7-5 IsDirectoryPath</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ IsDirectoryPath</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><a id="X81A0A4FF842B039B" name="X81A0A4FF842B039B"></a></p>

<h4>9.8 <span class="Heading">File Operations</span></h4>

<p><a id="X8373AC6B7D5F9167" name="X8373AC6B7D5F9167"></a></p>

<h5>9.8-1 Read</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Read</code>( <var class="Arg">filename</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>reads the input from the file with the filename <var class="Arg">filename</var>, which must be given as a string.</p>

<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>

<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>

<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</codeoutput 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</codecommand, 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>

<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>

<p>Note that one file may very well contain a read statement causing another file to be read, beforinput 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>

<p><a id="X7824CB7D7D4BAFBC" name="X7824CB7D7D4BAFBC"></a></p>

<h5>9.8-2 ReadAsFunction</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ReadAsFunction</code>( <var class="Arg">filename</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>reads the file with filename <var class="Arg">filename</var> as a function and returns this function.</p>

<p><em>Example</em></p>

<p>Suppose that the file <code class="file">/tmp/example.g</code> contains the following</p>


<div class="example"><pre>
local a;

a := 10;
return a*10;
</pre></div>

<p>Reading the file as a function will not affect a global variable <code class="code">a</code>.</p>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">a := 1;</span>
1
<span class="GAPprompt">gap></span> <span class="GAPinput">ReadAsFunction("/tmp/example.g")();</span>
100
<span class="GAPprompt">gap></span> <span class="GAPinput">a;</span>
1
</pre></div>

<p><a id="X86956C577FFEE1F9" name="X86956C577FFEE1F9"></a></p>

<h5>9.8-3 <span class="Heading">PrintTo and AppendTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PrintTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AppendTo</code>( <var class="Arg">filename</var>[, <var class="Arg">obj1</var>, <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><code class="func">AppendTo</code> works like <code class="func">PrintTo</code>, except that thoutput does not overwrite the previous contents of the file, but is appended to the file.</p>

<p>There is an upper limit of 15 on the number of output files that may be open simultaneously.</p>

<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>

<p><a id="X79813A6686894960" name="X79813A6686894960"></a></p>

<h5>9.8-4 <span class="Heading">LogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ LogTo</code>(  )</td><td class="tdright">( operation )</td></tr></table></div>
<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>

<p>Called without arguments, <code class="func">LogTo</code> stops logging to a file or stream.</p>

<p><a id="X7CAB119378B075B7" name="X7CAB119378B075B7"></a></p>

<h5>9.8-5 <span class="Heading">InputLogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ InputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ InputLogTo</code>(  )</td><td class="tdright">( operation )</td></tr></table></div>
<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>

<p>Called without arguments, <code class="func">InputLogTo</code> stops logging to a file or stream.</p>

<p><a id="X7A5591D87EAFA6CC" name="X7A5591D87EAFA6CC"></a></p>

<h5>9.8-6 <span class="Heading">OutputLogTo</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OutputLogTo</code>( <var class="Arg">filename</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ OutputLogTo</code>(  )</td><td class="tdright">( operation )</td></tr></table></div>
<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 samtime 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>

<p>Called without arguments, <code class="func">OutputLogTo</code> stops logging to a file or stream.</p>

<p><a id="X8241CEAD80415BB9" name="X8241CEAD80415BB9"></a></p>

<h5>9.8-7 CrcFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CrcFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function computes a CRC (cyclic redundancy check) number for the content of the file <var class="Arg">filename</var>.</p>

<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>


<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">CrcFile( "lib/morpheus.gi" );</span>
2705743645
</pre></div>

<p><a id="X7E63ACA38142BE96" name="X7E63ACA38142BE96"></a></p>

<h5>9.8-8 RemoveFile</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RemoveFile</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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>

<p><a id="X83F3B0337C7EA5CC" name="X83F3B0337C7EA5CC"></a></p>

<h5>9.8-9 UserHomeExpand</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ UserHomeExpand</code>( <var class="Arg">str</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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 GAPInfo.UserHome. Otherwise str is returned unchanged.



<p><a id="X79EE267A7FAF28A6" name="X79EE267A7FAF28A6"></a></p>

<h5>9.8-10 Reread</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Reread</code>( <var class="Arg">filename</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ REREADING</code></td><td class="tdright">( global variable )</td></tr></table></div>
<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>

<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</codeto <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>

<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>

<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>

<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>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap8.html">[Previous Chapter]</a>    <a href="chap10.html">[Next Chapter]</a>   </div>


<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>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

96%


¤ Dauer der Verarbeitung: 0.23 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.