Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 54143 invoked from network); 17 Jul 2006 19:49:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Jul 2006 19:49:15 -0000 Received: (qmail 89682 invoked by uid 500); 17 Jul 2006 19:49:15 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 89595 invoked by uid 500); 17 Jul 2006 19:49:15 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 89584 invoked by uid 99); 17 Jul 2006 19:49:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2006 12:49:15 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Jul 2006 12:49:14 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 34C961A981A; Mon, 17 Jul 2006 12:48:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r422821 - /incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java Date: Mon, 17 Jul 2006 19:48:53 -0000 To: harmony-commits@incubator.apache.org From: geirm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060717194854.34C961A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: geirm Date: Mon Jul 17 12:48:53 2006 New Revision: 422821 URL: http://svn.apache.org/viewvc?rev=422821&view=rev Log: cheap fix to solve the problem of there not being a file separator on temp or user home Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java Modified: incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java?rev=422821&r1=422820&r2=422821&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/logging/src/main/java/java/util/logging/FileHandler.java Mon Jul 17 12:48:53 2006 @@ -272,20 +272,34 @@ e1, ErrorManager.OPEN_FAILURE); } setOutputStream(output); - } - //apply settings, parse pattern and open files + /** + * Transform the pattern to the valid file name, replacing + * any patterns, and applying generation and uniqueID if + * present + * + * @param gen generation of this file + * @param uniqueID distinguishing id of this file + * @return transformed filename ready for use + */ private String parseFileName(int gen, int uniqueID) { int cur = 0; int next = 0; boolean hasUniqueID = false; boolean hasGeneration = false; - //TODO privilege code? + + //TODO privilege code? + String tempPath = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ + boolean tempPathHasSepEnd = (tempPath == null ? false : tempPath.endsWith(File.separator)); + String homePath = System.getProperty("user.home"); //$NON-NLS-1$ + boolean homePathHasSepEnd = (homePath == null ? false : homePath.endsWith(File.separator)); + StringBuffer sb = new StringBuffer(); pattern = pattern.replace('/', File.separatorChar); + char[] value = pattern.toCharArray(); while ((next = pattern.indexOf('%', cur)) >= 0) { if (++next < pattern.length()) { @@ -299,10 +313,20 @@ hasUniqueID = true; break; case 't': + /* + * we should probably try to do somethig cute here like + * lookahead for adjacent '/' + */ sb.append(value, cur, next - cur - 1).append(tempPath); + if (!tempPathHasSepEnd) { + sb.append(File.separator); + } break; case 'h': sb.append(value, cur, next - cur - 1).append(homePath); + if (!homePathHasSepEnd){ + sb.append(File.separator); + } break; case '%': sb.append(value, cur, next - cur - 1).append('%'); @@ -312,16 +336,20 @@ } cur = ++next; } else { - + // fail silently } } + sb.append(value, cur, value.length - cur); + if (!hasGeneration && count > 1) { sb.append(".").append(gen); //$NON-NLS-1$ } + if (!hasUniqueID && uniqueID > 0) { sb.append(".").append(uniqueID); //$NON-NLS-1$ } + return sb.toString(); }