/*
 * Copyright 2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.testkit.functional.internal;

import org.gradle.api.UncheckedIOException;
import org.gradle.internal.SystemProperties;

import java.io.File;
import java.io.IOException;

public class IsolatedDaemonHomeTmpDirectoryProvider implements TmpDirectoryProvider {
    public final static String DIR_NAME = ".gradle-test-kit";

    public File createDir() {
        try {
            File tmpDir = new File(new File(SystemProperties.getInstance().getJavaIoTmpDir()), DIR_NAME);

            if (!tmpDir.exists()) {
                if (!tmpDir.mkdirs()) {
                    throw new UncheckedIOException(String.format("Unable to create temporary directory %s", tmpDir.getCanonicalPath()));
                }
            }

            return tmpDir;
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
}

@@ -773,36 +773,8 @@
 ile;
-%0Aimport java.io.IOException;
 %0A%0Apu
@@ -954,26 +954,8 @@
 ) %7B%0A
-        try %7B%0A    
     
@@ -1052,21 +1052,16 @@
 _NAME);%0A
-%0A    
         
@@ -1076,68 +1076,45 @@
 Dir.
-exists()) %7B%0A                if (!tmpDir.mkdirs()) %7B%0A        
+mkdirs() && !tmpDir.isDirectory()) %7B%0A
     
@@ -1223,17 +1223,16 @@
 .get
-Canonical
+Absolute
 Path
@@ -1249,150 +1249,33 @@
     
- 
-       %7D%0A            %7D%0A%0A            return tmpDir;%0A        %7D catch (IOException e) %7B%0A            throw new UncheckedIOException(e);%0A        %7D
+%7D%0A%0A        return tmpDir;
 %0A   

Simplify temp dir creation.