Path: blob/master/test/jdk/tools/jpackage/share/EmptyFolderBase.java
41149 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.File;24import java.io.IOException;25import java.nio.file.Path;26import jdk.jpackage.test.TKit;2728public class EmptyFolderBase {2930// Note: To specify file use ".txt" extension.31// Note: createDirStrcture() will call mkdir() or createNewFile() for paths defined32// in dirStruct, so make sure paths are defined in order.3334// folder-empty35// folder-not-empty36// folder-not-empty/folder-empty37// folder-not-empty/another-folder-empty38// folder-not-empty/folder-non-empty239// folder-not-empty/folder-non-empty2/file.txt40private static final String [] DIR_STRUCT = {41"folder-empty",42"folder-not-empty",43"folder-not-empty" + File.separator + "folder-empty",44"folder-not-empty" + File.separator + "another-folder-empty",45"folder-not-empty" + File.separator + "folder-non-empty2",46"folder-not-empty" + File.separator + "folder-non-empty2" + File.separator +47"file.txt"48};4950// See dirStruct51public static void createDirStrcture(Path inputPath) throws IOException {52File input = new File(inputPath.toString());53input.mkdir();5455for (String p : DIR_STRUCT) {56File f = new File(input, p);57if (p.endsWith(".txt")) {58f.createNewFile();59} else {60f.mkdir();61}62}63}6465public static void validateDirStrcture(Path appDirPath) {66for (String p : DIR_STRUCT) {67Path path = appDirPath.resolve(p);68TKit.assertPathExists(path, true);69}70}71}727374