MCPcopy Index your code
hub / github.com/davidgiven/luje / OSFileSystem

Class OSFileSystem

lib/org/apache/harmony/luni/platform/OSFileSystem.java:29–299  ·  view source on GitHub ↗

This is the portable implementation of the file system interface.

Source from the content-addressed store, hash-verified

27 *
28 */
29class OSFileSystem implements IFileSystem {
30
31 static {
32 oneTimeInitializationImpl();
33 }
34
35 private static final OSFileSystem singleton = new OSFileSystem();
36
37 public static OSFileSystem getOSFileSystem() {
38 return singleton;
39 }
40
41 private OSFileSystem() {
42 super();
43 }
44
45 private native static void oneTimeInitializationImpl();
46
47 private final void validateLockArgs(int type, long start, long length) {
48 if ((type != IFileSystem.SHARED_LOCK_TYPE)
49 && (type != IFileSystem.EXCLUSIVE_LOCK_TYPE)) {
50 throw new IllegalArgumentException("Illegal lock type requested."); //$NON-NLS-1$
51 }
52
53 // Start position
54 if (start < 0) {
55 throw new IllegalArgumentException(
56 "Lock start position must be non-negative"); //$NON-NLS-1$
57 }
58
59 // Length of lock stretch
60 if (length < 0) {
61 throw new IllegalArgumentException(
62 "Lock length must be non-negative"); //$NON-NLS-1$
63 }
64 }
65
66 private native int lockImpl(long fileDescriptor, long start, long length,
67 int type, boolean wait);
68
69 /**
70 * Returns the granularity for virtual memory allocation.
71 * Note that this value for Windows differs from the one for the
72 * page size (64K and 4K respectively).
73 */
74 public native int getAllocGranularity() throws IOException;
75
76 public boolean lock(long fileDescriptor, long start, long length, int type,
77 boolean waitFlag) throws IOException {
78 // Validate arguments
79 validateLockArgs(type, start, length);
80 int result = lockImpl(fileDescriptor, start, length, type, waitFlag);
81 return result != -1;
82 }
83
84 private native int unlockImpl(long fileDescriptor, long start, long length);
85
86 public void unlock(long fileDescriptor, long start, long length)

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected