title: What is the best way to resolve a relative path (like realpath) for non-existing files?
body: <p>I'm trying to enforce a root directory in a filesystem abstraction. The problem I'm encountering is the following:</p>
  
  <p>The API lets you read and write files, not only to local but also remote storages. So there's all kinds of normalisation going on under the hood. At the moment it doesn't support relative paths, so something like this isn't possible:</p>
  
  <pre><code>$filesystem-&gt;write('path/to/some/../relative/file.txt', 'file contents');
  </code></pre>
  
  <p>I want to be able to securely resolve the path so the output is would be: <code>path/to/relative/file.txt</code>.
  As is stated in a github issue which was created for this bug/enhancement (<a href="https://github.com/FrenkyNet/Flysystem/issues/36#issuecomment-30319406">https://github.com/FrenkyNet/Flysystem/issues/36#issuecomment-30319406</a>) , it needs to do more that just splitting up segments and removing them accordingly.</p>
  
  <p>Also, since the package handles remote filesystems and non-existing files, realpath is out of the question.</p>
  
  <p>So, how should one go about when dealing with these paths?</p>