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 SolarisMailbox
extends Mailbox
{
22 private final String home
;
23 private final String user
;
25 private static final boolean homeRelative
=
26 Boolean
.getBoolean("mail.mbox.homerelative");
28 public SolarisMailbox() {
29 String h
= System
.getenv("HOME");
31 h
= System
.getProperty("user.home");
33 user
= System
.getProperty("user.name");
36 public MailFile
getMailFile(String user
, String folder
) {
37 if (folder
.equalsIgnoreCase("INBOX"))
38 return new UNIXInbox(user
, filename(user
, folder
));
40 return new UNIXFolder(filename(user
, folder
));
44 * Given a name of a mailbox folder, expand it to a full path name.
46 public String
filename(String user
, String folder
) {
48 switch (folder
.charAt(0)) {
52 int i
= folder
.indexOf(File
.separatorChar
);
55 tail
= folder
.substring(i
);
56 folder
= folder
.substring(0, i
);
58 if (folder
.length() == 1)
61 return "/home/" + folder
.substring(1) + tail
; // XXX
63 if (folder
.equalsIgnoreCase("INBOX")) {
64 if (user
== null) // XXX - should never happen
66 String inbox
= System
.getenv("MAIL");
68 inbox
= "/var/mail/" + user
;
72 return home
+ File
.separator
+ folder
;
77 } catch (StringIndexOutOfBoundsException e
) {