You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
30 KiB
HTML
2 lines
30 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>5 File</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">▼</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Sugar:<span class="mywbr"> </span> readability & convenience library</a></td></tr></table></div><div class="tocviewsublistonly" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="Installation___updates.html" class="tocviewlink" data-pltdoc="x">Installation & updates</a></td></tr><tr><td align="right">2 </td><td><a href="Coercion.html" class="tocviewlink" data-pltdoc="x">Coercion</a></td></tr><tr><td align="right">3 </td><td><a href="Container.html" class="tocviewlink" data-pltdoc="x">Container</a></td></tr><tr><td align="right">4 </td><td><a href="Debug.html" class="tocviewlink" data-pltdoc="x">Debug</a></td></tr><tr><td align="right">5 </td><td><a href="File.html" class="tocviewselflink" data-pltdoc="x">File</a></td></tr><tr><td align="right">6 </td><td><a href="Len.html" class="tocviewlink" data-pltdoc="x">Len</a></td></tr><tr><td align="right">7 </td><td><a href="License___source_code.html" class="tocviewlink" data-pltdoc="x">License & source code</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">get-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">has-<wbr></wbr>ext?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">remove-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">remove-<wbr></wbr>ext*</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">add-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">get-<wbr></wbr>enclosing-<wbr></wbr>dir</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.0.1.13</span></div><div class="navsettop"><span class="navleft"><div class="nosearchform"></div> </span><span class="navright"> <a href="Debug.html" title="backward to "4 Debug"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Sugar: readability & convenience library"" data-pltdoc="x">up</a> <a href="Len.html" title="forward to "6 Len"" data-pltdoc="x">next →</a></span> </div><h3>5<tt> </tt><a name="(part._.File)"></a><a name="(mod-path._sugar/file)"></a>File</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="File.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/file</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>File utilities, mostly in the realm of file extensions. These functions don’t access the filesystem.</p><p>Arguments that are <span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span> can take either a string or a path. For clarity below, I’ve used strings.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._get-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">get-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the last file extension of <span class="RktVar">file-path</span> as a string, or <span class="RktVal">#f</span> if it has no extension. Omit the intervening <span class="RktInBG"><span class="hspace"></span><span class="RktIn">.</span><span class="hspace"></span></span> separator.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"txt"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"txt"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"bar"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/file-without-extension"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/directory/"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._has-ext~3f))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">has-ext?</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span><span class="RktVar">ext</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">ext</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if the last file extension of <span class="RktVar">file-path</span> is <span class="RktVar">ext</span>, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.jpg.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._remove-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">remove-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Remove the last file extension of <span class="RktVar">file-path</span>, and return the path that remains. If <span class="RktVar">file-path</span> has no extension, you just get the same <span class="RktVar">file-path</span>. Does not use the filesystem.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo.txt></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._remove-ext*))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValDef RktValLink" data-pltdoc="x">remove-ext*</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span>, just more. Remove all file extensions from <span class="RktVar">file-path</span>, and return the path that remains. If <span class="RktVar">file-path</span> has no extensions, you just get the same <span class="RktVar">file-path</span>. Does not use the filesystem.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._add-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">add-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span><span class="RktVar">ext</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">ext</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return a new <span class="RktVar">file-path</span> with <span class="RktVar">ext</span> appended. Note that this does not replace an existing file extension. If that’s what you want, then do <span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="stt"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVar">ext</span><span class="RktPn">)</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo"</span><span class="hspace"> </span><span class="RktVal">"txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.txt></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.txt.jpg></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.jpg></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._get-enclosing-dir))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValDef RktValLink" data-pltdoc="x">get-enclosing-dir</a></span></span><span class="hspace"> </span><span class="RktVar">path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the enclosing directory of <span class="RktVar">path</span>. Does not consult the filesystem about whether <span class="RktVar">path</span> is valid. If you reach the <span class="RktVar">root</span> directory, then <span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="stt"> </span><span class="RktVar">root</span><span class="RktPn">)</span> will just return <span class="RktVar">root</span> again.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/usr/bin"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">bin</span></td></tr><tr><td><p><span class="RktRes">#<path:/usr/bin></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/usr/></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="File.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/></span></p></td></tr></table></blockquote></td></tr></table></p><div class="navsetbottom"><span class="navleft"><div class="nosearchform"></div> </span><span class="navright"> <a href="Debug.html" title="backward to "4 Debug"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Sugar: readability & convenience library"" data-pltdoc="x">up</a> <a href="Len.html" title="forward to "6 Len"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html> |