title: _wsplitpath_s() alternative to use with long paths
body: <p>I'm parsing paths by using the library function <a href="http://msdn.microsoft.com/en-us/library/8e46eyt7%28v=VS.80%29.aspx" rel="nofollow"><code>_wsplitpath_s()</code></a> to use with Win32 API functions.</p>
  
  <p>According to <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath" rel="nofollow">this MSDN document</a>, long paths (longer than <code>MAX_PATH</code> characters) must be perpended with with the prefix <code>\\?\</code>. However, when I perpend it to a full path string, <code>_wsplitpath_s()</code> cannot parse it correctly.</p>
  
  <p>Example code:</p>
  
  <pre><code>std::wstring FullPath = L"\\\\?\\K:\\A Directory\\Another Directory\\File Name.After Period.extension";
  std::wstring Drive, Directory, FileName, Extension;
  Drive.resize        (FullPath.size());
  Directory.resize    (FullPath.size());
  FileName.resize     (FullPath.size());
  Extension.resize    (FullPath.size());
  errno_t Error = _wsplitpath_s(  FullPath.c_str(),
                                  &amp;Drive[0],
                                  Drive.size(),
                                  &amp;Directory[0],
                                  Directory.size(),
                                  &amp;FileName[0],
                                  FileName.size(),
                                  &amp;Extension[0],
                                  Extension.size());
  std::wcout &lt;&lt; L"Full path to be splitted :    " &lt;&lt; FullPath.c_str()     &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Drive                    :    " &lt;&lt; Drive.c_str()        &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Directory                :    " &lt;&lt; Directory.c_str()    &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"File name                :    " &lt;&lt; FileName.c_str()     &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Extension                :    " &lt;&lt; Extension.c_str()    &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Error value returned     :    " &lt;&lt; Error                &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Did error occur?         :    " &lt;&lt; (Error == EINVAL)    &lt;&lt; std::endl;
  std::wcout &lt;&lt; L"Value of 'EINVAL'        :    " &lt;&lt; EINVAL               &lt;&lt; std::endl;
  </code></pre>
  
  <p>Actual output of the code above:</p>
  
  <pre><code>Full path to be splitted :    \\?\K:\A Directory\Another Directory\File Name.After Period.extension
  Drive                    :
  Directory                :    \\?\K:\A Directory\Another Directory\
  File name                :    File Name.After Period
  Extension                :    .extension
  Error value returned     :    0
  Did error occur?         :    0
  Value of 'EINVAL'        :    22
  </code></pre>
  
  <p>How it works with short paths:</p>
  
  <pre><code>Full path to be splitted :    K:\A Directory\Another Directory\File Name.After Period.extension
  Drive                    :    K:
  Directory                :    \A Directory\Another Directory\
  File name                :    File Name.After Period
  Extension                :    .extension
  </code></pre>
  
  <p>Expected behavior for long paths:</p>
  
  <pre><code>Full path to be splitted :    \\?\K:\A Directory\Another Directory\File Name.After Period.extension
  Drive                    :    K:
  Directory                :    \A Directory\Another Directory\
  File name                :    File Name.After Period
  Extension                :    .extension
  </code></pre>
  
  <p>Is there an alternative of <code>_wsplitpath_s()</code> which supports long path naming convention?<br>
  An STL algorithm, Win32 API function or a C library function is accepted in the given order.</p>