// Path: src/main/java/org/fest/util/Arrays.java
// public static <T> boolean isNullOrEmpty(@Nullable T[] array) {
//   return array == null || !hasElements(array);
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static java.io.File.separator;
import static java.lang.String.format;
import static org.fest.util.Arrays.isNullOrEmpty;
import static org.fest.util.Strings.concat;
import static org.fest.util.Strings.quote;
import static org.junit.Assert.assertTrue;
/*
 * Created on Sep 25, 2006
 * 
 * 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.
 * 
 * Copyright @2006-2013 the original author or authors.
 */
package org.fest.util;



/**
 * Creates and deletes directories in the file system.
 *
 * @author Yvonne Wang
 * @author Alex Ruiz
 */
public final class FolderFixture {
  private static Logger logger = Logger.getLogger(FolderFixture.class.getName());

  private final List<FolderFixture> folders = new ArrayList<FolderFixture>();
  private final List<FileFixture> files = new ArrayList<FileFixture>();

  private final String name;
  private final FolderFixture parent;

  private File dir;

  public FolderFixture(String name) {
    this(name, null);
  }

  public FolderFixture(String name, FolderFixture parent) {
    this.name = name;
    this.parent = parent;
    create();
  }

  File dir() {
    return dir;
  }

  private void create() {
    String path = relativePath();
    dir = new File(path);
    if (!dir.exists()) {
      assertTrue(dir.mkdir());
// Path: src/main/java/org/fest/util/Arrays.java
// public static <T> boolean isNullOrEmpty(@Nullable T[] array) {
//   return array == null || !hasElements(array);
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @NotNull String concat(@NotNull Object... objects) {
//   checkNotNull(objects);
//   StringBuilder b = new StringBuilder();
//   for (Object o : objects) {
//     b.append(o);
//   }
//   return b.toString();
// }
// 
// Path: src/main/java/org/fest/util/Strings.java
// public static @Nullable String quote(@Nullable String s) {
//   return s != null ? String.format("'%s'", s) : null;
// }


// Path: src/test/java/org/fest/util/FolderFixture.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import static java.io.File.separator;
import static java.lang.String.format;
import static org.fest.util.Arrays.isNullOrEmpty;
import static org.fest.util.Strings.concat;
import static org.fest.util.Strings.quote;
import static org.junit.Assert.assertTrue;

/*
 * Created on Sep 25, 2006
 * 
 * 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.
 * 
 * Copyright @2006-2013 the original author or authors.
 */
package org.fest.util;



/**
 * Creates and deletes directories in the file system.
 *
 * @author Yvonne Wang
 * @author Alex Ruiz
 */
public final class FolderFixture {
  private static Logger logger = Logger.getLogger(FolderFixture.class.getName());

  private final List<FolderFixture> folders = new ArrayList<FolderFixture>();
  private final List<FileFixture> files = new ArrayList<FileFixture>();

  private final String name;
  private final FolderFixture parent;

  private File dir;

  public FolderFixture(String name) {
    this(name, null);
  }

  public FolderFixture(String name, FolderFixture parent) {
    this.name = name;
    this.parent = parent;
    create();
  }

  File dir() {
    return dir;
  }

  private void create() {
    String path = relativePath();
    dir = new File(path);
    if (!dir.exists()) {
      assertTrue(dir.mkdir());
      logger.info(format("Created directory %s", quote(path)));