Return enum in LockDirectory
This makes it easier to add more Error cases in the future. Also, add
missing util namespace.
Return LockResult::ErrorWrite in LockDirectory
This allows the caller to remove a call to DirIsWritable(), which did a
similar check. Users should not notice any different behavior.
Remove DirIsWritable, GetUniquePath
This is a backport of core#28075