title: How to check if a file already exists before creating it? (C++, Unicode, cross platform)
body: <p>I have the following code which works on Windows:</p>
  
  <pre><code>bool fileExists(const wstring&amp; src)
  {
  #ifdef PLATFORM_WINDOWS
          return (_waccess(src.c_str(), 0) == 0);
  #else   
          // ???? how to make C access() function to accept the wstring on Unix/Linux/MacOS ?
  #endif
  }
  </code></pre>
  
  <p>How do I make the code work on *nix platforms the same way as it does on Windows, considering that <code>scr</code> is a Unicode string and might contain file path with Unicode characters?</p>
  
  <p>I have seen various StackOverflow answers which partly answer my question but I have problems to put it all together. My system relies on wide strings, especially on Windows where file names might contain non-ASCII characters. I know that generally it's better to write to the file and check for errors, but my case is the opposite - I need to skip the file if it already exists. I just want to check if the file exists, no matter if I can read/write it or not.</p>