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.*;
20:
21: public class UNIXFolder extends UNIXFile implements MailFile {
22: protected transient RandomAccessFile file;
23:
24: private static final long serialVersionUID = -254578891263785591L;
25:
26: public UNIXFolder(String name) {
27:         super(name);
28: }
29:
30: public boolean lock(String mode) {
31:         try {
32:          file = new RandomAccessFile(this, mode);
33:•         switch (lockType) {
34:          case NONE:
35:                 return true;
36:          case NATIVE:
37:          default:
38:                 return lock(file.getFD(), mode);
39:          case JAVA:
40:                 return file.getChannel().
41:•                 tryLock(0L, Long.MAX_VALUE, !mode.equals("rw")) != null;
42:          }
43:         } catch (FileNotFoundException fe) {
44:          return false;
45:         } catch (IOException ie) {
46:          file = null;
47:          return false;
48:         }
49: }
50:
51: public void unlock() {
52:•        if (file != null) {
53:          try {
54:                 file.close();
55:          } catch (IOException e) {
56:                 // ignore it
57:          }
58:          file = null;
59:         }
60: }
61:
62: public void touchlock() {
63: }
64:
65: public FileDescriptor getFD() {
66:•        if (file == null)
67:          return null;
68:         try {
69:          return file.getFD();
70:         } catch (IOException e) {
71:          return null;
72:         }
73: }
74: }