title: Recursing directories only goes one file deep
body: <p>I have the following code:</p>
  
  <pre><code>find_info(File) -&gt;
      case file:read_file_info(File) of
          {ok, Facts} -&gt; 
              case Facts#file_info.type of
                  directory -&gt; directory;
                  regular -&gt; regular
              end;
          {error,Reason} -&gt; exit(Reason)
      end.
  
  find_files(Dir,Flag,Ending,Acc) -&gt; 
      case file:list_dir(Dir) of
          {ok,A} -&gt; find_files_helper(A,Dir,Flag,Acc,Ending);
          {_,_} -&gt; Acc
      end. 
  
  find_files_helper([H|Tail],Dir,Flag,Acc,Ending) -&gt;
      A = find_info(filename:absname_join(Dir,H)),
      case A of
          directory -&gt; 
              case Flag of
                  true -&gt; 
                      find_files(filename:absname_join(Dir,H),Flag,Ending,Acc ++ find_files_helper(Tail,Dir,Flag,Acc,Ending));
                  false -&gt; find_files_helper(Tail,Dir,Flag,Acc,Ending)
              end;
          regular -&gt; 
          case filename:extension(H) of
              Ending -&gt; find_files_helper(Tail,Dir,Flag,[to_md5_large(H)] ++ Acc, Ending);
              _ -&gt; find_files_helper(Tail,Dir,Flag,Acc,Ending)
          end;
          {error,Reason} -&gt; exit(Reason)
      end;
  find_files_helper([],_,_,Acc,_) -&gt; Acc.
  </code></pre>
  
  <p>However whenever I run the find_files/4 the program only goes one file deep before crashing. 
  Say I have the following directory</p>
  
  <pre><code>home/
     a/
       ser.erl
     b/
     c/
  file.erl
  file2.erl
  </code></pre>
  
  <p>When run I will get the md5 of <code>file.erl</code> of <code>file2.erl</code> and of <code>ser.erl</code>. However if the directory looks like this:</p>
  
  <pre><code>home/
     a/
       ser.erl
       back.erl
     b/
     c/
  file.erl
  file2.erl
  </code></pre>
  
  <p>Then the whole program crashes. I have spent few good hours looking for what I'm missing here in my logic however I have no idea. </p>
  
  <p>The error message that I get is exception enoent  in function p:to_md5_large/1.</p>
  
  <p>In case the md5 is needed here it is:</p>
  
  <pre><code>to_md5_large(File)  -&gt;
  
          case file:read_file(File) of
              {ok, &lt;&lt;B/binary&gt;&gt;} -&gt; md5_helper(B,erlang:md5_init());
              {error,Reason} -&gt; exit(Reason)
          end.
  
  md5_helper(&lt;&lt;A:4/binary,B&gt;&gt;,Acc) -&gt; md5_helper(B,erlang:md5_update(Acc,A));
  md5_helper(A,Acc) -&gt; 
      B =     erlang:md5_update(Acc,A),
      erlang:md5_final(B).
  </code></pre>