about summary refs log tree commit diff stats
path: root/html/102persist.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-25 22:07:31 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-11-25 22:09:44 -0800
commit4beaf39d4ffa1502a1697f831cc5639e38aa7374 (patch)
tree2a0b1948997d27a8e8b8645b4d0fc139e4a82b94 /html/102persist.cc.html
parentf222051e01e05f2e9666235a5664536cb772d230 (diff)
downloadmu-4beaf39d4ffa1502a1697f831cc5639e38aa7374.tar.gz
3690
Attempting to write to a file in a non-existent directory silently
writes to a black hole in Unix. Make that explicit.
Diffstat (limited to 'html/102persist.cc.html')
-rw-r--r--html/102persist.cc.html1
1 files changed, 1 insertions, 0 deletions
diff --git a/html/102persist.cc.html b/html/102persist.cc.html
index 55961625..863546d2 100644
--- a/html/102persist.cc.html
+++ b/html/102persist.cc.html
@@ -130,6 +130,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span
     filename = read_mu_text<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
   <span class="Delimiter">}</span>
   ofstream fout<span class="Delimiter">((</span><span class="Constant">&quot;lesson/&quot;</span>+filename<span class="Delimiter">).</span>c_str<span class="Delimiter">());</span>
+  <span class="Normal">if</span> <span class="Delimiter">(</span>!fout<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
   string contents = read_mu_text<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span>
   fout &lt;&lt; contents<span class="Delimiter">;</span>
   fout<span class="Delimiter">.</span>close<span class="Delimiter">();</span>