You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ad...@apache.org on 2016/03/15 02:29:19 UTC
[06/15] incubator-mynewt-site git commit: working on code highlights
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_close/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_close/index.html b/os/modules/fs/fs/fs_close/index.html
index 5a77aa4..7831adc 100644
--- a/os/modules/fs/fs/fs_close/index.html
+++ b/os/modules/fs/fs/fs_close/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95close"><font color="#F2853F" style="font-size:24pt">fs_close</font><a class="headerlink" href="#fs95close" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_close(struct fs_file *file)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_close(struct fs_file *file)
+</pre></div>
+
<p>Closes the specified file and invalidates the file handle.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -808,12 +809,13 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>If the file has already been unlinked, and the file has no other open handles, the <code>fs_close()</code> function causes the file to be deleted from the disk.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>The below code opens the file <code>/settings/config.txt</code> for reading, reads some data, and then closes the file.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
read_config(void)
{
struct fs_file *file;
@@ -839,7 +841,7 @@ read_config(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_closedir/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_closedir/index.html b/os/modules/fs/fs/fs_closedir/index.html
index 6ee5ba7..5941e9b 100644
--- a/os/modules/fs/fs/fs_closedir/index.html
+++ b/os/modules/fs/fs/fs_closedir/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95closedir"><font color="#F2853F" style="font-size:24pt">fs_closedir</font><a class="headerlink" href="#fs95closedir" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_closedir(struct fs_dir *dir)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_closedir(struct fs_dir *dir)
+</pre></div>
+
<p>Closes the specified directory handle. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -806,55 +807,56 @@
<li><a href="../fs_return_codes/">FS error code</a> on failure</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.</p>
-<pre><code class="no-highlight">int
-traverse_dir(const char *dirname)
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #A90D91">int</span>
+<span style="color: #000000">traverse_dir</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">char</span> <span style="color: #000000">*dirname</span>)
{
- struct fs_dirent *dirent;
- struct fs_dir *dir;
- char buf[64];
- uint8_t name_len;
- int rc;
-
- rc = fs_opendir(dirname, &dir);
- if (rc != 0) {
- return -1;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dirent</span> <span style="color: #000000">*dirent</span>;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dir</span> <span style="color: #000000">*dir</span>;
+ <span style="color: #A90D91">char</span> <span style="color: #000000">buf</span><span style="color: #633820">[</span><span style="color: #1C01CE">64</span><span style="color: #633820">]</span>;
+ <span style="color: #000000">uint8_t</span> <span style="color: #000000">name_len</span>;
+ <span style="color: #A90D91">int</span> <span style="color: #000000">rc</span>;
+
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_opendir</span>(<span style="color: #000000">dirname</span>, <span style="color: #000000">&dir</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Iterate through the parent directory, printing the name of each child
- * entry. The loop only terminates via a function return.
- */
- while (1) {
- /* Retrieve the next child node. */
- rc = fs_readdir(dir, &dirent);
- if (rc == FS_ENOENT) {
- /* Traversal complete. */
- return 0;
- } else if (rc != 0) {
- /* Unexpected error. */
- return -1;
+ <span style="color: #177500">/* Iterate through the parent directory, printing the name of each child</span>
+<span style="color: #177500"> * entry. The loop only terminates via a function return.</span>
+<span style="color: #177500"> */</span>
+ <span style="color: #A90D91">while</span> (<span style="color: #1C01CE">1</span>) {
+ <span style="color: #177500">/* Retrieve the next child node. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_readdir</span>(<span style="color: #000000">dir</span>, <span style="color: #000000">&dirent</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #000000">FS_ENOENT</span>) {
+ <span style="color: #177500">/* Traversal complete. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #1C01CE">0</span>;
+ } <span style="color: #A90D91">else</span> <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #177500">/* Unexpected error. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Read the child node's name from the file system. */
- rc = fs_dirent_name(dirent, sizeof buf, buf, &name_len);
- if (rc != 0) {
- return -1;
+ <span style="color: #177500">/* Read the child node's name from the file system. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_dirent_name</span>(<span style="color: #000000">dirent</span>, <span style="color: #000000">sizeof</span> <span style="color: #000000">buf</span>, <span style="color: #000000">buf</span>, <span style="color: #000000">&name_len</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Print the child node's name to the console. */
- if (fs_dirent_is_dir(dirent)) {
- console_printf(" dir: ");
- } else {
- console_printf("file: ");
+ <span style="color: #177500">/* Print the child node's name to the console. */</span>
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">fs_dirent_is_dir</span>(<span style="color: #000000">dirent</span>)) {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">" dir: "</span>);
+ } <span style="color: #A90D91">else</span> {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"file: "</span>);
}
- console_printf("%s\n", buf);
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"%s\n"</span>, <span style="color: #000000">buf</span>);
}
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_dirent_is_dir/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_dirent_is_dir/index.html b/os/modules/fs/fs/fs_dirent_is_dir/index.html
index ebad60e..4059481 100644
--- a/os/modules/fs/fs/fs_dirent_is_dir/index.html
+++ b/os/modules/fs/fs/fs_dirent_is_dir/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95dirent95is95dir"><font color="#F2853F" style="font-size:24pt">fs_dirent_is_dir</font><a class="headerlink" href="#fs95dirent95is95dir" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_dirent_is_dir(const struct fs_dirent *dirent)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_dirent_is_dir(const struct fs_dirent *dirent)
+</pre></div>
+
<p>Tells you whether the specified directory entry is a sub-directory or a regular file. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -806,55 +807,56 @@
<li>0: The entry is a regular file.</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.</p>
-<pre><code class="no-highlight">int
-traverse_dir(const char *dirname)
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #A90D91">int</span>
+<span style="color: #000000">traverse_dir</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">char</span> <span style="color: #000000">*dirname</span>)
{
- struct fs_dirent *dirent;
- struct fs_dir *dir;
- char buf[64];
- uint8_t name_len;
- int rc;
-
- rc = fs_opendir(dirname, &dir);
- if (rc != 0) {
- return -1;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dirent</span> <span style="color: #000000">*dirent</span>;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dir</span> <span style="color: #000000">*dir</span>;
+ <span style="color: #A90D91">char</span> <span style="color: #000000">buf</span><span style="color: #633820">[</span><span style="color: #1C01CE">64</span><span style="color: #633820">]</span>;
+ <span style="color: #000000">uint8_t</span> <span style="color: #000000">name_len</span>;
+ <span style="color: #A90D91">int</span> <span style="color: #000000">rc</span>;
+
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_opendir</span>(<span style="color: #000000">dirname</span>, <span style="color: #000000">&dir</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Iterate through the parent directory, printing the name of each child
- * entry. The loop only terminates via a function return.
- */
- while (1) {
- /* Retrieve the next child node. */
- rc = fs_readdir(dir, &dirent);
- if (rc == FS_ENOENT) {
- /* Traversal complete. */
- return 0;
- } else if (rc != 0) {
- /* Unexpected error. */
- return -1;
+ <span style="color: #177500">/* Iterate through the parent directory, printing the name of each child</span>
+<span style="color: #177500"> * entry. The loop only terminates via a function return.</span>
+<span style="color: #177500"> */</span>
+ <span style="color: #A90D91">while</span> (<span style="color: #1C01CE">1</span>) {
+ <span style="color: #177500">/* Retrieve the next child node. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_readdir</span>(<span style="color: #000000">dir</span>, <span style="color: #000000">&dirent</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #000000">FS_ENOENT</span>) {
+ <span style="color: #177500">/* Traversal complete. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #1C01CE">0</span>;
+ } <span style="color: #A90D91">else</span> <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #177500">/* Unexpected error. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Read the child node's name from the file system. */
- rc = fs_dirent_name(dirent, sizeof buf, buf, &name_len);
- if (rc != 0) {
- return -1;
+ <span style="color: #177500">/* Read the child node's name from the file system. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_dirent_name</span>(<span style="color: #000000">dirent</span>, <span style="color: #000000">sizeof</span> <span style="color: #000000">buf</span>, <span style="color: #000000">buf</span>, <span style="color: #000000">&name_len</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Print the child node's name to the console. */
- if (fs_dirent_is_dir(dirent)) {
- console_printf(" dir: ");
- } else {
- console_printf("file: ");
+ <span style="color: #177500">/* Print the child node's name to the console. */</span>
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">fs_dirent_is_dir</span>(<span style="color: #000000">dirent</span>)) {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">" dir: "</span>);
+ } <span style="color: #A90D91">else</span> {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"file: "</span>);
}
- console_printf("%s\n", buf);
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"%s\n"</span>, <span style="color: #000000">buf</span>);
}
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_dirent_name/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_dirent_name/index.html b/os/modules/fs/fs/fs_dirent_name/index.html
index 9e6bcd1..de34fa1 100644
--- a/os/modules/fs/fs/fs_dirent_name/index.html
+++ b/os/modules/fs/fs/fs_dirent_name/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,9 +781,10 @@
</div>
<h2 id="fs95dirent95name"><font color="#F2853F" style="font-size:24pt">fs_dirent_name</font><a class="headerlink" href="#fs95dirent95name" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_dirent_name(const struct fs_dirent *dirent, size_t max_len,
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_dirent_name(const struct fs_dirent *dirent, size_t max_len,
char *out_name, uint8_t *out_name_len)
-</code></pre>
+</pre></div>
+
<p>Retrieves the filename of the specified directory entry. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -821,55 +822,56 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>The retrieved filename is always null-terminated. To ensure enough space to hold the full filename plus a null-termintor, a destination buffer of size <em>filename-max-length + 1</em> should be used.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.</p>
-<pre><code class="no-highlight">int
-traverse_dir(const char *dirname)
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #A90D91">int</span>
+<span style="color: #000000">traverse_dir</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">char</span> <span style="color: #000000">*dirname</span>)
{
- struct fs_dirent *dirent;
- struct fs_dir *dir;
- char buf[64];
- uint8_t name_len;
- int rc;
-
- rc = fs_opendir(dirname, &dir);
- if (rc != 0) {
- return -1;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dirent</span> <span style="color: #000000">*dirent</span>;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dir</span> <span style="color: #000000">*dir</span>;
+ <span style="color: #A90D91">char</span> <span style="color: #000000">buf</span><span style="color: #633820">[</span><span style="color: #1C01CE">64</span><span style="color: #633820">]</span>;
+ <span style="color: #000000">uint8_t</span> <span style="color: #000000">name_len</span>;
+ <span style="color: #A90D91">int</span> <span style="color: #000000">rc</span>;
+
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_opendir</span>(<span style="color: #000000">dirname</span>, <span style="color: #000000">&dir</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Iterate through the parent directory, printing the name of each child
- * entry. The loop only terminates via a function return.
- */
- while (1) {
- /* Retrieve the next child node. */
- rc = fs_readdir(dir, &dirent);
- if (rc == FS_ENOENT) {
- /* Traversal complete. */
- return 0;
- } else if (rc != 0) {
- /* Unexpected error. */
- return -1;
+ <span style="color: #177500">/* Iterate through the parent directory, printing the name of each child</span>
+<span style="color: #177500"> * entry. The loop only terminates via a function return.</span>
+<span style="color: #177500"> */</span>
+ <span style="color: #A90D91">while</span> (<span style="color: #1C01CE">1</span>) {
+ <span style="color: #177500">/* Retrieve the next child node. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_readdir</span>(<span style="color: #000000">dir</span>, <span style="color: #000000">&dirent</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #000000">FS_ENOENT</span>) {
+ <span style="color: #177500">/* Traversal complete. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #1C01CE">0</span>;
+ } <span style="color: #A90D91">else</span> <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #177500">/* Unexpected error. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Read the child node's name from the file system. */
- rc = fs_dirent_name(dirent, sizeof buf, buf, &name_len);
- if (rc != 0) {
- return -1;
+ <span style="color: #177500">/* Read the child node's name from the file system. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_dirent_name</span>(<span style="color: #000000">dirent</span>, <span style="color: #000000">sizeof</span> <span style="color: #000000">buf</span>, <span style="color: #000000">buf</span>, <span style="color: #000000">&name_len</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Print the child node's name to the console. */
- if (fs_dirent_is_dir(dirent)) {
- console_printf(" dir: ");
- } else {
- console_printf("file: ");
+ <span style="color: #177500">/* Print the child node's name to the console. */</span>
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">fs_dirent_is_dir</span>(<span style="color: #000000">dirent</span>)) {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">" dir: "</span>);
+ } <span style="color: #A90D91">else</span> {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"file: "</span>);
}
- console_printf("%s\n", buf);
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"%s\n"</span>, <span style="color: #000000">buf</span>);
}
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_filelen/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_filelen/index.html b/os/modules/fs/fs/fs_filelen/index.html
index 4e36bb4..ef3adf7 100644
--- a/os/modules/fs/fs/fs_filelen/index.html
+++ b/os/modules/fs/fs/fs_filelen/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95filelen"><font color="#F2853F" style="font-size:24pt">fs_filelen</font><a class="headerlink" href="#fs95filelen" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_filelen(const struct fs_file *file, uint32_t *out_len)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_filelen(const struct fs_file *file, uint32_t *out_len)
+</pre></div>
+
<p>Retrieves the current length of the specified open file.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -810,17 +811,18 @@
<li><a href="../fs_return_codes/">FS error code</a> on failure</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
write_config(void)
{
struct fs_file *file;
int rc;
- /* If the file doesn't exist, create it. If it does exist, truncate it to
+ /* If the file doesn't exist, create it. If it does exist, truncate it to
* zero bytes.
*/
rc = fs_open("/settings/config.txt", FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE,
@@ -839,7 +841,7 @@ write_config(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_getpos/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_getpos/index.html b/os/modules/fs/fs/fs_getpos/index.html
index 39a6221..6609724 100644
--- a/os/modules/fs/fs/fs_getpos/index.html
+++ b/os/modules/fs/fs/fs_getpos/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95getpos"><font color="#F2853F" style="font-size:24pt">fs_getpos</font><a class="headerlink" href="#fs95getpos" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">uint32_t fs_getpos(const struct fs_file *file)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">uint32_t fs_getpos(const struct fs_file *file)
+</pre></div>
+
<p>Retrieves the current read and write position of the specified open file. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -807,8 +808,8 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>If a file is opened in append mode, its write pointer is always positioned at the end of the file. Calling this function on such a file only indicates the read position.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_mkdir/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_mkdir/index.html b/os/modules/fs/fs/fs_mkdir/index.html
index 11d1702..0420150 100644
--- a/os/modules/fs/fs/fs_mkdir/index.html
+++ b/os/modules/fs/fs/fs_mkdir/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95mkdir"><font color="#F2853F" style="font-size:24pt">fs_mkdir</font><a class="headerlink" href="#fs95mkdir" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_mkdir(const char *path)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_mkdir(const char *path)
+</pre></div>
+
<p>Creates the directory represented by the specified path. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -808,12 +809,13 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>All intermediate directories must already exist. The specified path must start with a '/' character.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example demonstrates creating a series of nested directories.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
create_path(void)
{
int rc;
@@ -837,7 +839,7 @@ err:
fs_unlink("/data");
return -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_open/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_open/index.html b/os/modules/fs/fs/fs_open/index.html
index 1066534..3089246 100644
--- a/os/modules/fs/fs/fs_open/index.html
+++ b/os/modules/fs/fs/fs_open/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,20 +781,22 @@
</div>
<h2 id="fs95open"><font color="F2853F" style="font-size:24pt">fs_open</font><a class="headerlink" href="#fs95open" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_open(const char *filename, uint8_t access_flags,
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_open(const char *filename, uint8_t access_flags,
struct fs_file **out_file)
-</code></pre>
+</pre></div>
+
<p>Opens a file at the specified path. The result of opening a nonexistent file depends on the access flags specified. All intermediate directories must already exist.</p>
<p>The access flags are best understood by comparing them to their equivalent mode strings accepted by the C standard library function <code>fopen()</code>.
The mode strings passed to <code>fopen()</code> map to <code>fs_open()</code>'s access flags as follows:</p>
-<pre><code class="no-highlight">"r" - FS_ACCESS_READ
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">"r" - FS_ACCESS_READ
"r+" - FS_ACCESS_READ | FS_ACCESS_WRITE
"w" - FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE
"w+" - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE
"a" - FS_ACCESS_WRITE | FS_ACCESS_APPEND
"a+" - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_APPEND
-</code></pre>
+</pre></div>
+
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
<table>
@@ -834,12 +836,13 @@ The mode strings passed to <code>fopen()</code> map to <code>fs_open()</code>'s
</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>The below code opens the file <code>/settings/config.txt</code> for reading, reads some data, and then closes the file.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
read_config(void)
{
struct fs_file *file;
@@ -865,7 +868,7 @@ read_config(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_opendir/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_opendir/index.html b/os/modules/fs/fs/fs_opendir/index.html
index 8739a22..74213f8 100644
--- a/os/modules/fs/fs/fs_opendir/index.html
+++ b/os/modules/fs/fs/fs_opendir/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95opendir"><font color="#F2853F" style="font-size:24pt">fs_opendir</font><a class="headerlink" href="#fs95opendir" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_opendir(const char *path, struct fs_dir **out_dir)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_opendir(const char *path, struct fs_dir **out_dir)
+</pre></div>
+
<p>Opens the directory at the specified path. The directory's contents can be read with subsequent calls to fs_readdir(). When you are done with the directory handle, close it with fs_closedir(). </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -820,55 +821,56 @@
</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.</p>
-<pre><code class="no-highlight">int
-traverse_dir(const char *dirname)
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #A90D91">int</span>
+<span style="color: #000000">traverse_dir</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">char</span> <span style="color: #000000">*dirname</span>)
{
- struct fs_dirent *dirent;
- struct fs_dir *dir;
- char buf[64];
- uint8_t name_len;
- int rc;
-
- rc = fs_opendir(dirname, &dir);
- if (rc != 0) {
- return -1;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dirent</span> <span style="color: #000000">*dirent</span>;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dir</span> <span style="color: #000000">*dir</span>;
+ <span style="color: #A90D91">char</span> <span style="color: #000000">buf</span><span style="color: #633820">[</span><span style="color: #1C01CE">64</span><span style="color: #633820">]</span>;
+ <span style="color: #000000">uint8_t</span> <span style="color: #000000">name_len</span>;
+ <span style="color: #A90D91">int</span> <span style="color: #000000">rc</span>;
+
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_opendir</span>(<span style="color: #000000">dirname</span>, <span style="color: #000000">&dir</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Iterate through the parent directory, printing the name of each child
- * entry. The loop only terminates via a function return.
- */
- while (1) {
- /* Retrieve the next child node. */
- rc = fs_readdir(dir, &dirent);
- if (rc == FS_ENOENT) {
- /* Traversal complete. */
- return 0;
- } else if (rc != 0) {
- /* Unexpected error. */
- return -1;
+ <span style="color: #177500">/* Iterate through the parent directory, printing the name of each child</span>
+<span style="color: #177500"> * entry. The loop only terminates via a function return.</span>
+<span style="color: #177500"> */</span>
+ <span style="color: #A90D91">while</span> (<span style="color: #1C01CE">1</span>) {
+ <span style="color: #177500">/* Retrieve the next child node. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_readdir</span>(<span style="color: #000000">dir</span>, <span style="color: #000000">&dirent</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #000000">FS_ENOENT</span>) {
+ <span style="color: #177500">/* Traversal complete. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #1C01CE">0</span>;
+ } <span style="color: #A90D91">else</span> <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #177500">/* Unexpected error. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Read the child node's name from the file system. */
- rc = fs_dirent_name(dirent, sizeof buf, buf, &name_len);
- if (rc != 0) {
- return -1;
+ <span style="color: #177500">/* Read the child node's name from the file system. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_dirent_name</span>(<span style="color: #000000">dirent</span>, <span style="color: #000000">sizeof</span> <span style="color: #000000">buf</span>, <span style="color: #000000">buf</span>, <span style="color: #000000">&name_len</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Print the child node's name to the console. */
- if (fs_dirent_is_dir(dirent)) {
- console_printf(" dir: ");
- } else {
- console_printf("file: ");
+ <span style="color: #177500">/* Print the child node's name to the console. */</span>
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">fs_dirent_is_dir</span>(<span style="color: #000000">dirent</span>)) {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">" dir: "</span>);
+ } <span style="color: #A90D91">else</span> {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"file: "</span>);
}
- console_printf("%s\n", buf);
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"%s\n"</span>, <span style="color: #000000">buf</span>);
}
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_ops/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_ops/index.html b/os/modules/fs/fs/fs_ops/index.html
index a5b2882..4daadb9 100644
--- a/os/modules/fs/fs/fs_ops/index.html
+++ b/os/modules/fs/fs/fs_ops/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -611,7 +611,7 @@
</div>
<h2 id="struct-fs95ops"><font color="F2853F" style="font-size:24pt">struct fs_ops</font><a class="headerlink" href="#struct-fs95ops" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">struct fs_ops {
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">struct fs_ops {
int (*f_open)(const char *filename, uint8_t access_flags,
struct fs_file **out_file);
int (*f_close)(struct fs_file *file);
@@ -637,13 +637,14 @@
const char *f_name;
};
-</code></pre>
+</pre></div>
+
<p>This data structure consists of a set of function pointers. Each function pointer corresponds to a file system operation. When registering a file system with the abstraction layer, each function pointer must be pointed at the corresponding routine in the custom file system package.</p>
<p>The required behavior of each corresponding function is documented in the <a href="../fs/#api">file system abstraction layer API</a>.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs_if.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs_if.h"</span>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_read/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_read/index.html b/os/modules/fs/fs/fs_read/index.html
index 5572f69..8c2986e 100644
--- a/os/modules/fs/fs/fs_read/index.html
+++ b/os/modules/fs/fs/fs_read/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95read"><font color="#F2853F" style="font-size:24pt">fs_read</font><a class="headerlink" href="#fs95read" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_read(struct fs_file *file, uint32_t len, void *out_data, uint32_t *out_len)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_read(struct fs_file *file, uint32_t len, void *out_data, uint32_t *out_len)
+</pre></div>
+
<p>Reads data from the specified file. If more data is requested than remains in the file, all available data is retrieved and a success code is returned.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -818,12 +819,13 @@
<li><a href="../fs_return_codes/">FS error code</a> on failure</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>The below code opens the file <code>/settings/config.txt</code> for reading, reads some data, and then closes the file.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
read_config(void)
{
struct fs_file *file;
@@ -849,7 +851,7 @@ read_config(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_readdir/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_readdir/index.html b/os/modules/fs/fs/fs_readdir/index.html
index 3409d02..7919ded 100644
--- a/os/modules/fs/fs/fs_readdir/index.html
+++ b/os/modules/fs/fs/fs_readdir/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs_readdir"><font color="#F2853F" style="font-size:24pt">fs_readdir</font><a class="headerlink" href="#fs_readdir" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_readdir(struct fs_dir *dir, struct fs_dirent **out_dirent);
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_readdir(struct fs_dir *dir, struct fs_dirent **out_dirent);
+</pre></div>
+
<p>Reads the next entry in an open directory. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -811,55 +812,56 @@
<li>Other <a href="../fs_return_codes/">FS error code</a> on error.</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.</p>
-<pre><code class="no-highlight">int
-traverse_dir(const char *dirname)
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #A90D91">int</span>
+<span style="color: #000000">traverse_dir</span>(<span style="color: #A90D91">const</span> <span style="color: #A90D91">char</span> <span style="color: #000000">*dirname</span>)
{
- struct fs_dirent *dirent;
- struct fs_dir *dir;
- char buf[64];
- uint8_t name_len;
- int rc;
-
- rc = fs_opendir(dirname, &dir);
- if (rc != 0) {
- return -1;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dirent</span> <span style="color: #000000">*dirent</span>;
+ <span style="color: #000000">struct</span> <span style="color: #000000">fs_dir</span> <span style="color: #000000">*dir</span>;
+ <span style="color: #A90D91">char</span> <span style="color: #000000">buf</span><span style="color: #633820">[</span><span style="color: #1C01CE">64</span><span style="color: #633820">]</span>;
+ <span style="color: #000000">uint8_t</span> <span style="color: #000000">name_len</span>;
+ <span style="color: #A90D91">int</span> <span style="color: #000000">rc</span>;
+
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_opendir</span>(<span style="color: #000000">dirname</span>, <span style="color: #000000">&dir</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Iterate through the parent directory, printing the name of each child
- * entry. The loop only terminates via a function return.
- */
- while (1) {
- /* Retrieve the next child node. */
- rc = fs_readdir(dir, &dirent);
- if (rc == FS_ENOENT) {
- /* Traversal complete. */
- return 0;
- } else if (rc != 0) {
- /* Unexpected error. */
- return -1;
+ <span style="color: #177500">/* Iterate through the parent directory, printing the name of each child</span>
+<span style="color: #177500"> * entry. The loop only terminates via a function return.</span>
+<span style="color: #177500"> */</span>
+ <span style="color: #A90D91">while</span> (<span style="color: #1C01CE">1</span>) {
+ <span style="color: #177500">/* Retrieve the next child node. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_readdir</span>(<span style="color: #000000">dir</span>, <span style="color: #000000">&dirent</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">==</span> <span style="color: #000000">FS_ENOENT</span>) {
+ <span style="color: #177500">/* Traversal complete. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #1C01CE">0</span>;
+ } <span style="color: #A90D91">else</span> <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #177500">/* Unexpected error. */</span>
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Read the child node's name from the file system. */
- rc = fs_dirent_name(dirent, sizeof buf, buf, &name_len);
- if (rc != 0) {
- return -1;
+ <span style="color: #177500">/* Read the child node's name from the file system. */</span>
+ <span style="color: #000000">rc</span> <span style="color: #000000">=</span> <span style="color: #000000">fs_dirent_name</span>(<span style="color: #000000">dirent</span>, <span style="color: #000000">sizeof</span> <span style="color: #000000">buf</span>, <span style="color: #000000">buf</span>, <span style="color: #000000">&name_len</span>);
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">rc</span> <span style="color: #000000">!=</span> <span style="color: #1C01CE">0</span>) {
+ <span style="color: #A90D91">return</span> <span style="color: #000000">-</span><span style="color: #1C01CE">1</span>;
}
- /* Print the child node's name to the console. */
- if (fs_dirent_is_dir(dirent)) {
- console_printf(" dir: ");
- } else {
- console_printf("file: ");
+ <span style="color: #177500">/* Print the child node's name to the console. */</span>
+ <span style="color: #A90D91">if</span> (<span style="color: #000000">fs_dirent_is_dir</span>(<span style="color: #000000">dirent</span>)) {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">" dir: "</span>);
+ } <span style="color: #A90D91">else</span> {
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"file: "</span>);
}
- console_printf("%s\n", buf);
+ <span style="color: #000000">console_printf</span>(<span style="color: #C41A16">"%s\n"</span>, <span style="color: #000000">buf</span>);
}
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_register/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_register/index.html b/os/modules/fs/fs/fs_register/index.html
index 58c07b5..4a4c843 100644
--- a/os/modules/fs/fs/fs_register/index.html
+++ b/os/modules/fs/fs/fs_register/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95register"><font color="F2853F" style="font-size:24pt">fs_register</font><a class="headerlink" href="#fs95register" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_register(const struct fs_ops *fops)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_register(const struct fs_ops *fops)
+</pre></div>
+
<p>Registers a file system with the abstraction layer. On success, all calls into <code>fs/fs</code> will use the registered file system.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -808,8 +809,8 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>Only one file system can be registered. The registered file system is mounted in the root directory (<em>/</em>).</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_rename/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_rename/index.html b/os/modules/fs/fs/fs_rename/index.html
index 7b06c77..7960a1b 100644
--- a/os/modules/fs/fs/fs_rename/index.html
+++ b/os/modules/fs/fs/fs_rename/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95rename"><font color="#F2853F" style="font-size:24pt">fs_rename</font><a class="headerlink" href="#fs95rename" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_rename(const char *from, const char *to)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_rename(const char *from, const char *to)
+</pre></div>
+
<p>Performs a rename and / or move of the specified source path to the specified destination. The source path can refer to a file or a directory.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -812,12 +813,13 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>The source path can refer to either a file or a directory. All intermediate directories in the destination path must already exist. If the source path refers to a file, the destination path must contain a full filename path, rather than just the new parent directory. If an object already exists at the specified destination path, this function causes it to be unlinked prior to the rename (i.e., the destination gets clobbered).</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example demonstrates how to use fs_rename() to perform a log rotation. In this example, there is one primary log and three archived logs. <code>FS_ENOENT</code> errors returned by <code>fs_rename()</code> are ignored; it is not an error if an archived log was never created.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
rotate_logs(void)
{
struct fs_file *file;
@@ -846,7 +848,7 @@ rotate_logs(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_return_codes/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_return_codes/index.html b/os/modules/fs/fs/fs_return_codes/index.html
index 5f35bf2..4884be7 100644
--- a/os/modules/fs/fs/fs_return_codes/index.html
+++ b/os/modules/fs/fs/fs_return_codes/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -665,8 +665,8 @@
</tbody>
</table>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_seek/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_seek/index.html b/os/modules/fs/fs/fs_seek/index.html
index 7aa0325..ad629ac 100644
--- a/os/modules/fs/fs/fs_seek/index.html
+++ b/os/modules/fs/fs/fs_seek/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95seek"><font color="#F2853F" style="font-size:24pt">fs_seek</font><a class="headerlink" href="#fs95seek" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_seek(struct fs_file *file, uint32_t offset)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_seek(struct fs_file *file, uint32_t offset)
+</pre></div>
+
<p>Positions a file's read and write pointer at the specified offset. The offset is expressed as the number of bytes from the start of the file (i.e., seeking to offset 0 places the pointer at the first byte in the file).</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -812,12 +813,13 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>If a file is opened in append mode, its write pointer is always positioned at the end of the file. Calling this function on such a file only affects the read pointer.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>The following example reads four bytes from a file, starting at an offset of eight.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
read_part1_middle(void)
{
struct fs_file *file;
@@ -844,7 +846,7 @@ read_part1_middle(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_unlink/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_unlink/index.html b/os/modules/fs/fs/fs_unlink/index.html
index a21ff8b..989856b 100644
--- a/os/modules/fs/fs/fs_unlink/index.html
+++ b/os/modules/fs/fs/fs_unlink/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95unlink"><font color="#F2853F" style="font-size:24pt">fs_unlink</font><a class="headerlink" href="#fs95unlink" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_unlink(const char *filename)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_unlink(const char *filename)
+</pre></div>
+
<p>Unlinks the file or directory at the specified path. This is the function to use if you want to delete a file or directory from the disk. If the path refers to a directory, all the directory's descendants are recursively unlinked. Any open file handles refering to an unlinked file remain valid, and can be read from and written to as long as they remain open.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -806,18 +807,19 @@
<li><a href="../fs_return_codes/">FS error code</a> on failure</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>The following example creates a file and then immediately unlinks it. By unlinking the file, this function prevents other OS tasks from accessing it. When the function closes the file, it is deleted from the disk.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
process_data(void)
{
struct fs_file *file;
int rc;
- /* If the file doesn't exist, create it. If it does exist, truncate it to
+ /* If the file doesn't exist, create it. If it does exist, truncate it to
* zero bytes.
*/
rc = fs_open("/tmp/buffer.bin", FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE, &file);
@@ -836,7 +838,7 @@ process_data(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fs_write/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fs_write/index.html b/os/modules/fs/fs/fs_write/index.html
index 6c8f155..e0a419c 100644
--- a/os/modules/fs/fs/fs_write/index.html
+++ b/os/modules/fs/fs/fs_write/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fs95write"><font color="#F2853F" style="font-size:24pt">fs_write</font><a class="headerlink" href="#fs95write" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fs_write(struct fs_file *file, const void *data, int len)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fs_write(struct fs_file *file, const void *data, int len)
+</pre></div>
+
<p>Writes the supplied data to the current offset of the specified file handle. </p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -816,17 +817,18 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>For files opened in append mode, the specified data is always written to the end.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
write_config(void)
{
struct fs_file *file;
int rc;
- /* If the file doesn't exist, create it. If it does exist, truncate it to
+ /* If the file doesn't exist, create it. If it does exist, truncate it to
* zero bytes.
*/
rc = fs_open("/settings/config.txt", FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE,
@@ -845,7 +847,7 @@ write_config(void)
return rc == 0 ? 0 : -1;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fsutil_read_file/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fsutil_read_file/index.html b/os/modules/fs/fs/fsutil_read_file/index.html
index 0ba2e2c..d736ced 100644
--- a/os/modules/fs/fs/fsutil_read_file/index.html
+++ b/os/modules/fs/fs/fsutil_read_file/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,9 +781,10 @@
</div>
<h2 id="fsutil95read95file"><font color="#F2853F" style="font-size:24pt">fsutil_read_file</font><a class="headerlink" href="#fsutil95read95file" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fsutil_read_file(const char *path, uint32_t offset, uint32_t len,
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fsutil_read_file(const char *path, uint32_t offset, uint32_t len,
void *dst, uint32_t *out_len)
-</code></pre>
+</pre></div>
+
<p>Calls fs_open(), fs_read(), and fs_close() to open a file at the specified path, retrieve data from the file starting from the specified offset, and close the file and invalidate the file handle.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -825,12 +826,13 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>This is a convenience function. It is useful when the amount of data to be read from the file is small (i.e., all the data read can easily fit in a single buffer).</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example demonstrates reading a small text file in its entirety and printing its contents to the console.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
print_status(void)
{
uint32_t bytes_read;
@@ -843,14 +845,14 @@ print_status(void)
if (rc != 0) return -1;
/* Null-terminate the string just read. */
- buf[bytes_read] = '\0';
+ buf[bytes_read] = '\0';
/* Print the file contents to the console. */
console_printf("%s\n", buf);
return 0;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/fs/fsutil_write_file/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/fs/fsutil_write_file/index.html b/os/modules/fs/fs/fsutil_write_file/index.html
index 39d9076..142f8d1 100644
--- a/os/modules/fs/fs/fsutil_write_file/index.html
+++ b/os/modules/fs/fs/fsutil_write_file/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -781,8 +781,9 @@
</div>
<h2 id="fsutil95write95file"><font color="#F2853F" style="font-size:24pt">fsutil_write_file</font><a class="headerlink" href="#fsutil95write95file" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">int fsutil_write_file(const char *path, const void *data, uint32_t len)
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int fsutil_write_file(const char *path, const void *data, uint32_t len)
+</pre></div>
+
<p>Calls fs_open(), fs_write(), and fs_close() to open a file at the specified path, write the supplied data to the current offset of the specified file handle, and close the file and invalidate the file handle. If the specified file already exists, it is truncated and overwritten with the specified data.</p>
<h4 id="arguments">Arguments<a class="headerlink" href="#arguments" title="Permanent link">¶</a></h4>
@@ -814,12 +815,13 @@
<li><a href="../fs_return_codes/">FS error code</a> on failure</li>
</ul>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "fs/fs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "fs/fs.h"</span>
+</pre></div>
+
<h4 id="example">Example<a class="headerlink" href="#example" title="Permanent link">¶</a></h4>
<p>This example creates a 4-byte file.</p>
-<pre><code class="no-highlight">int
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">int
write_id(void)
{
int rc;
@@ -838,7 +840,7 @@ write_id(void)
return 0;
}
-</code></pre>
+</pre></div>
<div class="row">
<footer>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/nffs/nffs/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/nffs/nffs/index.html b/os/modules/fs/nffs/nffs/index.html
index 7a0485f..3120065 100644
--- a/os/modules/fs/nffs/nffs/index.html
+++ b/os/modules/fs/nffs/nffs/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -624,56 +624,59 @@
</ol>
<p>Both methods require the user to describe how the flash memory should be divided into nffs areas. This is accomplished with an array of <a href="../nffs_area_desc/">struct nffs_area_desc</a>.</p>
<p>Typically, a product's flash layout is exposed via its BSP-specific <code>bsp_flash_dev()</code> function. This function retrieves the layout of the specified flash device resident in the BSP. The result of this function can then be converted into the <code>struct nffs_area_desc[]</code> that nffs requires. The below example, taken from the slinky project, illustrates the nffs initialization procedure.</p>
-<pre><code class="no-highlight">/*** hw/hal/include/hal/flash_map.h */
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #177500">/*** hw/hal/include/hal/flash_map.h */</span>
-/*
- * Flash area types
- */
-#define FLASH_AREA_BOOTLOADER 0
-#define FLASH_AREA_IMAGE_0 1
-#define FLASH_AREA_IMAGE_1 2
-#define FLASH_AREA_IMAGE_SCRATCH 3
-#define FLASH_AREA_NFFS 4
-</code></pre>
+<span style="color: #177500">/*</span>
+<span style="color: #177500"> * Flash area types</span>
+<span style="color: #177500"> */</span>
+<span style="color: #000000">#</span>define FLASH_AREA_BOOTLOADER <span style="color: #1C01CE">0</span>
+<span style="color: #000000">#</span>define FLASH_AREA_IMAGE_0 <span style="color: #1C01CE">1</span>
+<span style="color: #000000">#</span>define FLASH_AREA_IMAGE_1 <span style="color: #1C01CE">2</span>
+<span style="color: #000000">#</span>define FLASH_AREA_IMAGE_SCRATCH <span style="color: #1C01CE">3</span>
+<span style="color: #000000">#</span>define FLASH_AREA_NFFS <span style="color: #1C01CE">4</span>
+</pre></div>
-<pre><code class="no-highlight">/*** project/slinky/src/main.c */
+
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #177500">/*** project/slinky/src/main.c */</span>
int
-main(int argc, char **argv)
-{
- int rc;
- int cnt;
-
- /* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */
- struct nffs_area_desc descs[NFFS_AREA_MAX];
-
- /* Initialize nffs's internal state. */
- rc = nffs_init();
- assert(rc == 0);
-
- /* Convert the set of flash blocks we intend to use for nffs into an array
- * of nffs area descriptors.
- */
- cnt = NFFS_AREA_MAX;
- rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, descs);
- assert(rc == 0);
-
- /* Attempt to restore an existing nffs file system from flash. */
- if (nffs_detect(descs) == FS_ECORRUPT) {
- /* No valid nffs instance detected; format a new one. */
- rc = nffs_format(descs);
- assert(rc == 0);
- }
- /* [ ... ] */
-}
-</code></pre>
+main<span style="color: #000000">(</span>int argc<span style="color: #000000">,</span> char <span style="color: #000000">**</span>argv<span style="color: #000000">)</span>
+<span style="color: #000000">{</span>
+ int rc<span style="color: #000000">;</span>
+ int cnt<span style="color: #000000">;</span>
+
+ <span style="color: #177500">/* NFFS_AREA_MAX is defined in the BSP-specified bsp.h header file. */</span>
+ struct nffs_area_desc descs<span style="color: #000000">[</span>NFFS_AREA_MAX<span style="color: #000000">];</span>
+
+ <span style="color: #177500">/* Initialize nffs's internal state. */</span>
+ rc <span style="color: #000000">=</span> nffs_init<span style="color: #000000">();</span>
+ assert<span style="color: #000000">(</span>rc <span style="color: #000000">==</span> <span style="color: #1C01CE">0</span><span style="color: #000000">);</span>
+
+ <span style="color: #177500">/* Convert the set of flash blocks we intend to use for nffs into an array</span>
+<span style="color: #177500"> * of nffs area descriptors.</span>
+<span style="color: #177500"> */</span>
+ cnt <span style="color: #000000">=</span> NFFS_AREA_MAX<span style="color: #000000">;</span>
+ rc <span style="color: #000000">=</span> flash_area_to_nffs_desc<span style="color: #000000">(</span>FLASH_AREA_NFFS<span style="color: #000000">,</span> <span style="color: #000000">&</span>cnt<span style="color: #000000">,</span> descs<span style="color: #000000">);</span>
+ assert<span style="color: #000000">(</span>rc <span style="color: #000000">==</span> <span style="color: #1C01CE">0</span><span style="color: #000000">);</span>
+
+ <span style="color: #177500">/* Attempt to restore an existing nffs file system from flash. */</span>
+ <span style="color: #A90D91">if</span> <span style="color: #000000">(</span>nffs_detect<span style="color: #000000">(</span>descs<span style="color: #000000">)</span> <span style="color: #000000">==</span> FS_ECORRUPT<span style="color: #000000">)</span> <span style="color: #000000">{</span>
+ <span style="color: #177500">/* No valid nffs instance detected; format a new one. */</span>
+ rc <span style="color: #000000">=</span> nffs_format<span style="color: #000000">(</span>descs<span style="color: #000000">);</span>
+ assert<span style="color: #000000">(</span>rc <span style="color: #000000">==</span> <span style="color: #1C01CE">0</span><span style="color: #000000">);</span>
+ <span style="color: #000000">}</span>
+ <span style="color: #177500">/* [ ... ] */</span>
+<span style="color: #000000">}</span>
+</pre></div>
+
<p>After nffs has been initialized, the application can access the file system via the <a href="../../fs/fs/">file system abstraction layer</a>.</p>
<h3 id="configuration">Configuration<a class="headerlink" href="#configuration" title="Permanent link">¶</a></h3>
<p>The nffs file system is configured by populating fields in a global <a href="../nffs_config/">struct nffs_config</a> instance. Each field in the structure corresponds to a setting. All configuration must be done prior to calling nffs_init().</p>
<p>The global <code>struct nffs_config</code> instance is exposed in <code>nffs/nffs.h</code> as follows:</p>
-<pre><code class="no-highlight">extern struct nffs_config nffs_config;
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">extern struct nffs_config nffs_config;
+</pre></div>
+
<h3 id="data-structures">Data Structures<a class="headerlink" href="#data-structures" title="Permanent link">¶</a></h3>
<p>The <code>fs/nffs</code> package exposes the following data structures:</p>
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/44646ca9/os/modules/fs/nffs/nffs_area_desc/index.html
----------------------------------------------------------------------
diff --git a/os/modules/fs/nffs/nffs_area_desc/index.html b/os/modules/fs/nffs/nffs_area_desc/index.html
index d9b0601..2fd51c0 100644
--- a/os/modules/fs/nffs/nffs_area_desc/index.html
+++ b/os/modules/fs/nffs/nffs_area_desc/index.html
@@ -202,7 +202,7 @@
<li><a href="
- ../../../../get_started/project1/
+ ../../../../get_started/native_tools/
">Get Started</a>
@@ -226,7 +226,7 @@
<li><a href="
- ../../../../tutorials/STM32F303/
+ ../../../../tutorials/olimex/
">Tutorials</a>
@@ -621,12 +621,13 @@
</div>
<h2 id="struct-nffs95area95desc"><font color="F2853F" style="font-size:24pt">struct nffs_area_desc</font><a class="headerlink" href="#struct-nffs95area95desc" title="Permanent link">¶</a></h2>
-<pre><code class="no-highlight">struct nffs_area_desc {
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%">struct nffs_area_desc {
uint32_t nad_offset; /* Flash offset of start of area. */
uint32_t nad_length; /* Size of area, in bytes. */
uint8_t nad_flash_id; /* Logical flash id */
};
-</code></pre>
+</pre></div>
+
<p>Descriptor for a single nffs area. An area is a region of disk with the following properties:</p>
<ol>
@@ -640,8 +641,8 @@
<h4 id="notes">Notes<a class="headerlink" href="#notes" title="Permanent link">¶</a></h4>
<p>Typically, a product's flash layout is exposed via its BSP-specific <code>bsp_flash_dev()</code> function. This function retrieves the layout of the specified flash device resident in the BSP. The result of this function can then be converted into the <code>struct nffs_area_desc[]</code> that nffs requires.</p>
<h4 id="header-file">Header file<a class="headerlink" href="#header-file" title="Permanent link">¶</a></h4>
-<pre><code class="no-highlight">#include "nffs/nffs.h"
-</code></pre>
+<div class="codehilite" style="background: #ffffff"><pre style="line-height: 125%"><span style="color: #633820">#include "nffs/nffs.h"</span>
+</pre></div>
<div class="row">
<footer>