<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Daniel Duan's Articles About Minute Swift</title>
        <link>https://duan.ca/tag/minute-swift/</link>
        <atom:link href="https://duan.ca/tag/minute-swift/feed.xml" rel="self" type="application/rss+xml" />
            <item>
                <title>Building &#39;pwd&#39; Under 1 Minute In Swift</title>
                <description>&#60;p&#62;I guess I&#39;m starting a series of minute-long videos. In this first video, I built &#60;code&#62;pwd&#60;/code&#62; out of &#60;code&#62;getcwd&#60;/code&#62;. The
code turned out shorter than I imagined (1 line). Which is a good demonstration of Swift&#39;s great C-interop
capability.&#60;/p&#62;
&#60;div class=&#34;video-container&#34;&#62;
    &#60;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube.com/embed/YR4MCcMnHrI&#34; frameborder=&#34;0&#34; gesture=&#34;media&#34; allow=&#34;encrypted-media&#34; allowfullscreen&#62;&#60;/iframe&#62;
&#60;/div&#62;
&#60;p&#62;Some details are lost in this video, however. For example, the POSIX standard actually says &#60;code&#62;getcwd&#60;/code&#62;&#39;s 2nd
argument being &#60;code&#62;0&#60;/code&#62; is undefined. Luckily, both macOS and Linux define it the way we want (allocate as much
memory as needed). Swift&#39;s handling of &#60;code&#62;char *&#60;/code&#62; aka &#60;code&#62;UnsafeMutablePointer&#38;lt;CChar&#38;gt;&#60;/code&#62; in context of a &#60;code&#62;var&#60;/code&#62; array
is also very cool.&#60;/p&#62;
</description>
                <pubDate>Wed, 27 Dec 2017 01:13:07 -0800</pubDate>
                <link>https://duan.ca/2017/12/27/building-pwd-under-1-minute-in-swift/</link>
                <guid isPermaLink="true">https://duan.ca/2017/12/27/building-pwd-under-1-minute-in-swift/</guid>
            </item>
    </channel>
</rss>