Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/EmptyFolderBase.java
41149 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.io.File;
25
import java.io.IOException;
26
import java.nio.file.Path;
27
import jdk.jpackage.test.TKit;
28
29
public class EmptyFolderBase {
30
31
// Note: To specify file use ".txt" extension.
32
// Note: createDirStrcture() will call mkdir() or createNewFile() for paths defined
33
// in dirStruct, so make sure paths are defined in order.
34
35
// folder-empty
36
// folder-not-empty
37
// folder-not-empty/folder-empty
38
// folder-not-empty/another-folder-empty
39
// folder-not-empty/folder-non-empty2
40
// folder-not-empty/folder-non-empty2/file.txt
41
private static final String [] DIR_STRUCT = {
42
"folder-empty",
43
"folder-not-empty",
44
"folder-not-empty" + File.separator + "folder-empty",
45
"folder-not-empty" + File.separator + "another-folder-empty",
46
"folder-not-empty" + File.separator + "folder-non-empty2",
47
"folder-not-empty" + File.separator + "folder-non-empty2" + File.separator +
48
"file.txt"
49
};
50
51
// See dirStruct
52
public static void createDirStrcture(Path inputPath) throws IOException {
53
File input = new File(inputPath.toString());
54
input.mkdir();
55
56
for (String p : DIR_STRUCT) {
57
File f = new File(input, p);
58
if (p.endsWith(".txt")) {
59
f.createNewFile();
60
} else {
61
f.mkdir();
62
}
63
}
64
}
65
66
public static void validateDirStrcture(Path appDirPath) {
67
for (String p : DIR_STRUCT) {
68
Path path = appDirPath.resolve(p);
69
TKit.assertPathExists(path, true);
70
}
71
}
72
}
73
74