title: How do I check if a directory is a file or folder?
body: <p>Okay, so I'm using mingW, and the direct struct has no variables named d_type or stat, d_stat, or dd_stat. I need to know how I can use my direct struct to figure out if what I have is a file or folder. Here is my code.</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;dirent.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  /*function... might want it in some class?*/
  int getdir (string dir, vector&lt;string&gt; &amp;files)
  {
      DIR *dp;
      struct stat _buf;
      struct dirent *dirp;
      if((dp  = opendir(dir.c_str())) == NULL) {
          cout &lt;&lt; "Error(" &lt;&lt; errno &lt;&lt; ") opening " &lt;&lt; dir &lt;&lt; endl;
          return errno;
      }
  
      while ((dirp = readdir(dp)) != NULL) {
  
          if(stat(dirp-&gt;d_name, &amp;_buf) != 0x4)
          files.push_back(string(dirp-&gt;d_name));
      }
      closedir(dp);
      return 0;
  }
  
  int main()
  {
      string dir = string(".");
      vector&lt;string&gt; files = vector&lt;string&gt;();
  
      getdir(dir,files);
  
      for (unsigned int i = 0;i &lt; files.size();i++) {
          cout &lt;&lt; files[i] &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>