2 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
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.
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.
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17 package com
.sun
.mail
.mbox
;
21 public class DefaultMailbox
extends Mailbox
{
22 private final String home
;
24 private static final boolean homeRelative
=
25 Boolean
.getBoolean("mail.mbox.homerelative");
27 public DefaultMailbox() {
28 home
= System
.getProperty("user.home");
31 public MailFile
getMailFile(String user
, String folder
) {
32 return new DefaultMailFile(filename(user
, folder
));
35 public String
filename(String user
, String folder
) {
37 char c
= folder
.charAt(0);
38 if (c
== File
.separatorChar
) {
40 } else if (c
== '~') {
41 int i
= folder
.indexOf(File
.separatorChar
);
44 tail
= folder
.substring(i
);
45 folder
= folder
.substring(0, i
);
49 if (folder
.equalsIgnoreCase("INBOX"))
52 return home
+ File
.separator
+ folder
;
56 } catch (StringIndexOutOfBoundsException e
) {
62 class DefaultMailFile
extends File
implements MailFile
{
63 protected transient RandomAccessFile file
;
65 private static final long serialVersionUID
= 3713116697523761684L;
67 DefaultMailFile(String name
) {
71 public boolean lock(String mode
) {
73 file
= new RandomAccessFile(this, mode
);
75 } catch (FileNotFoundException fe
) {
77 } catch (IOException ie
) {
83 public void unlock() {
87 } catch (IOException e
) {
94 public void touchlock() {
97 public FileDescriptor
getFD() {
102 } catch (IOException e
) {