Recognize file type in C++
<p>I implemented a solution to the problem meant to be cross-platform and adherent to the C++ standard library.</p>

<pre><code>bool isdir(const char *string) {
   ofstream file(string, ios::out);
   return file.fail();
}
</code></pre>

<p>Yet, if the file is actually writable, the program opens an empty file with <code>string</code> name in its working directory.
How can I prevent this from happening?</p>
