Packages

File, Directory, and Path handling in Gleam

Current section

Files

Jump to
gleam_file gen docs gleam path index.html
Raw

gen/docs/gleam/path/index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>gleam&#x2f;path - gleam_file</title>
<link rel="stylesheet" href="..&#x2f;../index.css" type="text/css" />
</head>
<body>
<header class="page-header">
<h2>
gleam_file<!-- - -->
</h2>
</header>
<div class="page">
<nav class="sidebar">
<a class="sidebar-toggle" href="#">
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="bars"
class="svg-inline--fa fa-bars fa-w-14"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
>
<path
fill="#fff"
d="M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"
>
</path>
</svg>
</a>
<h2>Pages</h2>
<ul>
<li><a href="..&#x2f;../index.html">README</a></li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="https:&#x2f;&#x2f;gitlab.com&#x2f;greggreg&#x2f;gleam_file">Source</a></li>
</ul>
<h2>Modules</h2>
<ul>
<li><a href="..&#x2f;../gleam&#x2f;file&#x2f;">gleam&#x2f;file</a></li>
<li><a href="..&#x2f;../gleam&#x2f;path&#x2f;">gleam&#x2f;path</a></li>
<li><a href="..&#x2f;../gleam&#x2f;posix_errors&#x2f;">gleam&#x2f;posix_errors</a></li>
</ul>
<h2>Types</h2>
<ul>
<li><a href="#Kind">Kind</a></li>
</ul>
<h2>Functions</h2>
<ul>
<li><a href="#absolute">absolute</a></li>
<li><a href="#basename">basename</a></li>
<li><a href="#extension">extension</a></li>
<li><a href="#join">join</a></li>
<li><a href="#kind">kind</a></li>
<li><a href="#split">split</a></li>
</ul>
</nav>
<main class="content">
<h1 class="module-name">gleam&#x2f;path</h1>
<section class="module-members">
<a href="#module-types">
<h1 id="module-types" class="module-member-kind">Types</h1>
</a>
<div class="member">
<a href="#Kind">
<h2 id="Kind" class="member-name">
Kind
</h2>
</a>
<div class="custom-type-constructors">
<div class="rendered-markdown"></div>
<pre>pub type Kind {
Relative
Absolute
Volumerelative
}</pre>
<h3>
Constructors
</h3>
<ul>
<li>
<code class="constructor-name">Relative</code>
</li>
<li>
<code class="constructor-name">Absolute</code>
</li>
<li>
<code class="constructor-name">Volumerelative</code>
</li>
</ul>
</div>
</div>
</section>
<section class="module-members">
<a href="#module-functions">
<h1 id="module-functions" class="module-member-kind">Functions</h1>
</a>
<div class="member">
<a href="#absolute">
<h2 id="absolute" class="member-name">
absolute
</h2>
</a>
<pre>pub external fn absolute(path: String) -&gt; String</pre>
<div class="rendered-markdown"><p>Converts a relative path and returns an absolute path.
No attempt is made to create the shortest absolute path,
as this can give incorrect results on file systems that allow links.</p>
</div>
</div>
<div class="member">
<a href="#basename">
<h2 id="basename" class="member-name">
basename
</h2>
</a>
<pre>pub external fn basename(path: String) -&gt; String</pre>
<div class="rendered-markdown"><p>Returns the filename portion of a path</p>
<h2>Examples</h2>
<pre><code>&gt; path.basename(&quot;foo&quot;)
&quot;foo&quot;
&gt; path.basename(&quot;/usr/foo&quot;)
&quot;foo&quot;
&gt; path.basename(&quot;/&quot;)
</code></pre>
<p>&quot;&quot;</p>
</div>
</div>
<div class="member">
<a href="#extension">
<h2 id="extension" class="member-name">
extension
</h2>
</a>
<pre>pub external fn extension(path: String) -&gt; String</pre>
<div class="rendered-markdown"><p>Returns the extension portion of a path, including the period.</p>
<h2>Examples</h2>
<pre><code>&gt; path.extension(&quot;foo.gleam&quot;)
</code></pre>
<p>&quot;.gleam&quot;
&gt; path.extension(&quot;beam.src/kalle&quot;)
&quot;&quot;</p>
</div>
</div>
<div class="member">
<a href="#join">
<h2 id="join" class="member-name">
join
</h2>
</a>
<pre>pub external fn join(path: List(String)) -&gt; String</pre>
<div class="rendered-markdown"><p>Joins a list of path parts with directory separators.
If one of the path parts includes an absolute path, such as &quot;/xxx&quot;,
the preceding elements, if any, are removed from the result.</p>
<p>The result is &quot;normalized&quot;:
Redundant directory separators are removed.
In Windows, all directory separators are forward slashes and the drive letter is in lower case.</p>
</div>
</div>
<div class="member">
<a href="#kind">
<h2 id="kind" class="member-name">
kind
</h2>
</a>
<pre>pub fn kind(path: String) -&gt; Kind</pre>
<div class="rendered-markdown"><p>Returns the path type.</p>
<h2>Examples</h2>
<h3>Unix-like operating systems</h3>
<pre><code> path.kind(&quot;/&quot;) #=&gt; Absolute
path.kind(&quot;/usr/local/bin&quot;) #=&gt; Absolute
path.kind(&quot;usr/local/bin&quot;) #=&gt; Relative
path.kind(&quot;../usr/local/bin&quot;) #=&gt; Relative
path.kind(&quot;~/file&quot;) #=&gt; Relative
</code></pre>
<h3>Windows</h3>
<pre><code> path.kind(&quot;D:/usr/local/bin&quot;) #=&gt; Absolute
path.kind(&quot;usr/local/bin&quot;) #=&gt; Relative
path.kind(&quot;D:bar.ex&quot;) #=&gt; Volumerelative
path.kind(&quot;/bar/foo.ex&quot;) #=&gt; Volumerelative</code></pre>
</div>
</div>
<div class="member">
<a href="#split">
<h2 id="split" class="member-name">
split
</h2>
</a>
<pre>pub external fn split(path: String) -&gt; List(String)</pre>
<div class="rendered-markdown"><p>Splits the path into a list at the path separator.
If an empty string is given, returns an empty list.
On Windows, path is split on both &quot;&quot; and &quot;/&quot; separators
and the driver letter, if there is one, is always returned
in lowercase.</p>
<h2>Examples</h2>
<pre><code> &gt; path.split(&quot;&quot;)
[]
&gt; path.split(&quot;foo&quot;)
[&quot;foo&quot;]
&gt; path.split(&quot;/foo/bar&quot;)
[&quot;/&quot;, &quot;foo&quot;, &quot;bar&quot;]</code></pre>
</div>
</div>
</section>
</main>
</div>
<script>const pride = () => document.querySelector('body').classList.toggle('show-pride')</script>
<a class="pride-button" onclick="pride()"></a>
<footer class="pride" onclick="pride()">
<div class="blue">Lucy</div>
<div class="pink">says</div>
<div class="white">trans</div>
<div class="pink">rights</div>
<div class="blue"></div>
</footer>
</body>
</html>