-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfilesystem.html
119 lines (117 loc) · 3.89 KB
/
filesystem.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<html dir="ltr">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>Arc: File system operations</title>
<link rel="shortcut icon" href="/assets/favicon.png">
<link rel="stylesheet" type="text/css" href="code.css">
<link href="/assets/bootstrap.css" rel="stylesheet">
</head>
<body style='margin:12px 50px 0'>
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<ul class="nav navbar-nav">
<li><a href="/ref/">Arc 3.1</a>
<li><a href="http://tryarc.org">Try it</a></li>
<li><a href="http://github.com/arclanguage/anarki">Get it</a></li>
<li><a href="http://ycombinator.com/arc/tut.txt">Tutorial</a></li>
<li><a href="http://arclanguage.org/forum">Forum</a></li>
</ul>
</div>
</div> <!-- end of navbar -->
<div class="links">Previous: <a href="io.html">I/O in the Arc language</a>
Up: <a href="index.html">Contents</a>
Next: <a href="threading.html">Threads</a>
</div>
<h1 class="links">File system operations</h1>
Arc has operations to manipulate files and directories. These operations do not all work on non-Unix systems. The I/O operations are closely related to MzScheme's <a
href='http://download.plt-scheme.org/doc/mzscheme/mzscheme-Z-H-11.html#node_chap_11'>I/O
operations</a>.
<p>See <a href='io.html'>I/O in Arc</a> for information on reading and writing files.
<h2></h2>
<p><table class='arc'>
<tr>
<td class='arc'><a name='ensure-dir'></a>
<img src='proc.gif' title='Procedure'/>
<span class='op'>ensure-dir</span> <span class='args'>path</span>
<div class='desc'>Creates the specified directory, if it doesn't exist.</div>
</td>
<td class='arc'><pre>
>(ensure-dir "newdir")
<span class="return">nil
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='dir'></a>
<img src='foundation.gif' title='Foundation'/>
<span class='op'>dir</span> <span class='args'>path</span>
<div class='desc'>Returns the directory contents as a list.</div>
</td>
<td class='arc'><pre>
>(dir "mydir")
<span class="return">("foo")
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='dir-exists'></a>
<img src='foundation.gif' title='Foundation'/>
<img src='predicate.gif' title='Predicate'/>
<span class='op'>dir-exists</span> <span class='args'>path</span>
<div class='desc'>Tests if a directory exists.</div>
</td>
<td class='arc'><pre>
>(dir-exists "mydir")
<span class="return">"mydir"
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='file-exists'></a>
<img src='foundation.gif' title='Foundation'/>
<img src='predicate.gif' title='Predicate'/>
<span class='op'>file-exists</span> <span class='args'>path</span>
<div class='desc'>Tests if a file exists.</div>
</td>
<td class='arc'><pre>
>(file-exists "mydir")
<span class="return">nil
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='mvfile'></a>
<img src='foundation.gif' title='Foundation'/>
<span class='op'>mvfile</span> <span class='args'>path</span>
<div class='desc'>Moves the specified file. New in arc3.</div>
</td>
<td class='arc'><pre>
>(mvfile "/tmp/junk" "/tmp/newjunk")
nil
</pre>
</td></tr>
<tr>
<td class='arc'><a name='rmfile'></a>
<img src='foundation.gif' title='Foundation'/>
<span class='op'>rmfile</span> <span class='args'>path</span>
<div class='desc'>Removes the specified file.</div>
</td>
<td class='arc'><pre>
>(rmfile "/tmp/newjunk")
<span class="stdout">Error: delete-file: cannot delete file
path: /tmp/newjunk
system error: No such file or directory; errno=2
</span></pre>
</td></tr>
<tr>
<td class='arc'><a name='rmfile'></a>
<img src='foundation.gif' title='Foundation'/>
<span class='op'>rmfile</span> <span class='args'>path</span>
<div class='desc'>Removes the specified file.</div>
</td>
<td class='arc'><pre>
>(rmfile "oldfile")
nil
</pre>
</td></tr>
</table>
<p>
Copyright 2008 Ken Shirriff.
</body>
</html>