Current section
Files
Jump to
Current section
Files
gen/docs/gleam/path/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>gleam/path - gleam_file</title>
<link rel="stylesheet" href="../../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="../../index.html">README</a></li>
</ul>
<h2>Links</h2>
<ul>
<li><a href="https://gitlab.com/greggreg/gleam_file">Source</a></li>
</ul>
<h2>Modules</h2>
<ul>
<li><a href="../../gleam/file/">gleam/file</a></li>
<li><a href="../../gleam/path/">gleam/path</a></li>
<li><a href="../../gleam/posix_errors/">gleam/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/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) -> 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) -> String</pre>
<div class="rendered-markdown"><p>Returns the filename portion of a path</p>
<h2>Examples</h2>
<pre><code>> path.basename("foo")
"foo"
> path.basename("/usr/foo")
"foo"
> path.basename("/")
</code></pre>
<p>""</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) -> String</pre>
<div class="rendered-markdown"><p>Returns the extension portion of a path, including the period.</p>
<h2>Examples</h2>
<pre><code>> path.extension("foo.gleam")
</code></pre>
<p>".gleam"
> path.extension("beam.src/kalle")
""</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)) -> 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 "/xxx",
the preceding elements, if any, are removed from the result.</p>
<p>The result is "normalized":
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) -> 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("/") #=> Absolute
path.kind("/usr/local/bin") #=> Absolute
path.kind("usr/local/bin") #=> Relative
path.kind("../usr/local/bin") #=> Relative
path.kind("~/file") #=> Relative
</code></pre>
<h3>Windows</h3>
<pre><code> path.kind("D:/usr/local/bin") #=> Absolute
path.kind("usr/local/bin") #=> Relative
path.kind("D:bar.ex") #=> Volumerelative
path.kind("/bar/foo.ex") #=> 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) -> 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 "" and "/" separators
and the driver letter, if there is one, is always returned
in lowercase.</p>
<h2>Examples</h2>
<pre><code> > path.split("")
[]
> path.split("foo")
["foo"]
> path.split("/foo/bar")
["/", "foo", "bar"]</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>