Re-implemented Path::createDirectoryOnDisk (for Unix).
authorTed Kremenek <kremenek@apple.com>
Thu, 3 Apr 2008 16:11:31 +0000 (16:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 3 Apr 2008 16:11:31 +0000 (16:11 +0000)
commitc5412c58d2dd6c89e4b03c7c446d69a6b01e7a3f
treeb6f4b548e180389ae59a8c8d8fea9e6f53d48130
parent43b7ca15a3f5c80847e078d2201e935ffc3e0e4a
Re-implemented Path::createDirectoryOnDisk (for Unix).

This method allows one to create a directory, and optionally create all parent
directories that do not exist.

The original implementation would require that *all* directories along a path
are writable by the user, including directories that already exist. For example,
suppose we wanted to create the directory "/tmp/foo/bar", and the directory
"/tmp" already exists, but not "/tmp/foo". Since "/tmp" is writable by all
users, the original implementation would work, and create "/tmp/foo", followed
by "/tmp/bar".

A problem occurred, however if one wanted to created the directory
"/Users/myuser/bar" (or equivalently "/home/myuser/bar"), and "/Users/myuser"
already existed and is writable by the current user. The directory
"/User/myuser" is writable by the user, but "/User" is not. The original
implementation of createDirectoryOnDisk would return with failure since "/User"
is not writable, even though "/User/mysuser" is writable.

The new implementation works by recursively creating parents as needed, and thus
doesn't need to check the permissions on every directory in a path.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49162 91177308-0d34-0410-b5e6-96231b3b80d8
lib/System/Unix/Path.inc