Skip to content

Package: UNIXFolder

UNIXFolder

nameinstructionbranchcomplexitylinemethod
UNIXFolder(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getFD()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
lock(String)
M: 44 C: 0
0%
M: 7 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
touchlock()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
unlock()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.mbox;
18:
19: import java.io.FileDescriptor;
20: import java.io.FileNotFoundException;
21: import java.io.IOException;
22: import java.io.RandomAccessFile;
23:
24: public class UNIXFolder extends UNIXFile implements MailFile {
25: protected transient RandomAccessFile file;
26:
27: private static final long serialVersionUID = -254578891263785591L;
28:
29: public UNIXFolder(String name) {
30: super(name);
31: }
32:
33: public boolean lock(String mode) {
34: try {
35: file = new RandomAccessFile(this, mode);
36:• switch (lockType) {
37: case NONE:
38: return true;
39: case NATIVE:
40: default:
41: return lock(file.getFD(), mode);
42: case JAVA:
43: return file.getChannel().
44:• tryLock(0L, Long.MAX_VALUE, !mode.equals("rw")) != null;
45: }
46: } catch (FileNotFoundException fe) {
47: return false;
48: } catch (IOException ie) {
49: file = null;
50: return false;
51: }
52: }
53:
54: public void unlock() {
55:• if (file != null) {
56: try {
57: file.close();
58: } catch (IOException e) {
59: // ignore it
60: }
61: file = null;
62: }
63: }
64:
65: public void touchlock() {
66: }
67:
68: public FileDescriptor getFD() {
69:• if (file == null)
70: return null;
71: try {
72: return file.getFD();
73: } catch (IOException e) {
74: return null;
75: }
76: }
77: }