Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java
41137 views
1
/*
2
* Copyright (c) 2008, 2012, 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. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.nio.fs;
27
28
import java.nio.file.*;
29
import java.io.IOException;
30
import java.util.*;
31
import java.security.AccessController;
32
import sun.security.action.GetPropertyAction;
33
34
/**
35
* Bsd implementation of FileSystem
36
*/
37
38
class BsdFileSystem extends UnixFileSystem {
39
40
BsdFileSystem(UnixFileSystemProvider provider, String dir) {
41
super(provider, dir);
42
}
43
44
@Override
45
public WatchService newWatchService()
46
throws IOException
47
{
48
// use polling implementation until we implement a BSD/kqueue one
49
return new PollingWatchService();
50
}
51
52
// lazy initialization of the list of supported attribute views
53
private static class SupportedFileFileAttributeViewsHolder {
54
static final Set<String> supportedFileAttributeViews =
55
supportedFileAttributeViews();
56
private static Set<String> supportedFileAttributeViews() {
57
Set<String> result = new HashSet<String>();
58
result.addAll(standardFileAttributeViews());
59
// additional BSD-specific views
60
result.add("user");
61
return Collections.unmodifiableSet(result);
62
}
63
}
64
65
@Override
66
public Set<String> supportedFileAttributeViews() {
67
return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
68
}
69
70
@Override
71
void copyNonPosixAttributes(int ofd, int nfd) {
72
UnixUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
73
}
74
75
/**
76
* Returns object to iterate over mount entries
77
*/
78
@Override
79
Iterable<UnixMountEntry> getMountEntries() {
80
ArrayList<UnixMountEntry> entries = new ArrayList<UnixMountEntry>();
81
try {
82
long iter = BsdNativeDispatcher.getfsstat();
83
try {
84
for (;;) {
85
UnixMountEntry entry = new UnixMountEntry();
86
int res = BsdNativeDispatcher.fsstatEntry(iter, entry);
87
if (res < 0)
88
break;
89
entries.add(entry);
90
}
91
} finally {
92
BsdNativeDispatcher.endfsstat(iter);
93
}
94
95
} catch (UnixException x) {
96
// nothing we can do
97
}
98
return entries;
99
}
100
101
102
103
@Override
104
FileStore getFileStore(UnixMountEntry entry) throws IOException {
105
return new BsdFileStore(this, entry);
106
}
107
}
108
109