1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.2 -->
<HTML>
<HEAD>
<TITLE>filelib</TITLE>
<SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
<STYLE TYPE="text/css">
<!--
.REFBODY { margin-left: 13mm }
.REFTYPES { margin-left: 8mm }
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
<IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>filelib</H1>
</CENTER>
<H3>MODULE</H3>
<DIV CLASS=REFBODY>
filelib
</DIV>
<H3>MODULE SUMMARY</H3>
<DIV CLASS=REFBODY>
File utilities, such as wildcard matching of filenames
</DIV>
<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>
<P>This module contains utilities on a higher level than the <CODE>file</CODE>
module.
</DIV>
<H3>EXPORTS</H3>
<P><A NAME="ensure_dir/1"><STRONG><CODE>ensure_dir(Name) -> true</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Name = filename() | dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>ensure_dir/1</CODE> functions checks that all parent directories
for the given file or directory name exist, creating them if not.
</DIV>
<P><A NAME="file_size/1"><STRONG><CODE>file_size(Filename) -> integer()</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY>
<P>The <CODE>file_size</CODE> function returns the size of the given file.
</DIV>
<P><A NAME="fold_files/5"><STRONG><CODE>fold_files(Dir, RegExp, Recursive, Fun, AccIn) -> AccOut </CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Dir = dirname()</CODE></STRONG><BR>
<STRONG><CODE>RegExp = regexp()</CODE></STRONG><BR>
<STRONG><CODE>Recursive = true|false</CODE></STRONG><BR>
<STRONG><CODE>Fun = fun(F, AccIn) -> AccOut</CODE></STRONG><BR>
<STRONG><CODE>AccIn = AccOut = term()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>fold_files/5</CODE> function folds the function
<CODE>Fun</CODE> over all (regular) files <CODE>F</CODE> in the
directory <CODE>Dir</CODE> that match the regular expression <CODE>RegExp</CODE>.
If <CODE>Recursive</CODE> is true all sub-directories to <CODE>Dir</CODE>
are processed. The match is tried on just the filename without
the directory part.
</DIV>
<P><A NAME="is_dir/1"><STRONG><CODE>is_dir(Name) -> true | false</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Name = filename() | dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>is_dir/1</CODE> function returns <CODE>true</CODE> if <CODE>Name</CODE>
refers to a directory, and <CODE>false</CODE> otherwise.
</DIV>
<P><A NAME="is_file/1"><STRONG><CODE>is_file(Name) -> true | false</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Name = filename() | dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>is_file/1</CODE> function returns <CODE>true</CODE> if <CODE>Name</CODE>
refers to a file or a directory, and <CODE>false</CODE> otherwise.
</DIV>
<P><A NAME="is_regular/1"><STRONG><CODE>is_regular(Name) -> true | false</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Name = filename()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>is_regular/1</CODE> function returns <CODE>true</CODE> if <CODE>Name</CODE>
refers to a file (regular file), and <CODE>false</CODE> otherwise.
</DIV>
<P><A NAME="last_modified/1"><STRONG><CODE>last_modified(Name) -> {{Year,Month,Day},{Hour,Min,Sec}}</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Name = filename() | dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>last_modified/1</CODE> function returns the date and time the
given file or directory was last modified.
</DIV>
<P><A NAME="wildcard/1"><STRONG><CODE>wildcard(Wildcard) -> list()</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Wildcard = filename() | dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>wildcard/1</CODE> function returns a list of all files
that match Unix-style wildcard-string <CODE>Wildcard</CODE>.
<P>The wildcard string looks like an ordinary filename, except
that certain "wildcard characters" are interpreted in a special
way. The following characters are special:
<P>
<DL>
<DT>
?
</DT>
<DD>
Matches one character.<BR>
</DD>
<DT>
*
</DT>
<DD>
Matches any number of characters up to the end of
the filename, the next dot, or the next slash.<BR>
</DD>
<DT>
{Item,...}
</DT>
<DD>
Alternation. Matches one of the alternatives.<BR>
</DD>
</DL>
<P>Other characters represent themselves. Only filenames that
have exactly the same character in the same position will match.
(Matching is case-sensitive; i.e. "a" will not match "A").
<P>Note that multiple "*" characters are allowed
(as in Unix wildcards, but opposed to Windows/DOS wildcards).
<P>Examples:
<P>The following examples assume that the current directory is the
top of an Erlang/OTP installation.
<P>To find all <CODE>.beam</CODE> files in all applications, the following
line can be used:
<PRE>
filelib:wildcard("lib/*/ebin/*.beam").
</PRE>
<P>To find either <CODE>.erl</CODE> or <CODE>.hrl</CODE> in all applications
<CODE>src</CODE> directories, the following
<PRE>
filelib:wildcard("lib/*/src/*.?rl")
</PRE>
<P>or the following line
<PRE>
filelib:wildcard("lib/*/src/*.{erl,hrl}")
</PRE>
<P>can be used.
<P>To find all <CODE>.hrl</CODE> files in either <CODE>src</CODE> or <CODE>include</CODE>
directories, use:
<PRE>
filelib:wildcard("lib/*/{src,include}/*.hrl").
</PRE>
<P>To find all <CODE>.erl</CODE> or <CODE>.hrl</CODE> files in either
<CODE>src</CODE> or <CODE>include</CODE> directories, use:
<PRE>
filelib:wildcard("lib/*/{src,include}/*.{erl,hrl}")
</PRE>
</DIV>
<P><A NAME="wildcard/2"><STRONG><CODE>wildcard(Wildcard, Cwd) -> list()</CODE></STRONG></A><BR>
<DIV CLASS=REFBODY><P>Types:
<DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>Wildcard = filename() | dirname()</CODE></STRONG><BR>
<STRONG><CODE>Cwd = dirname()</CODE></STRONG><BR>
</DIV>
</DIV>
<DIV CLASS=REFBODY>
<P>The <CODE>wildcard/2</CODE> function works like <CODE>wildcard/1</CODE>,
except that instead of the actual working dirctory, <CODE>Cwd</CODE>
will be used.
</DIV>
<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
Bjorn Gustavsson - support@erlang.ericsson.se<BR>
</DIV>
<CENTER>
<HR>
<SMALL>stdlib 1.13.2<BR>
Copyright © 1991-2004
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>
|