From 3916f2cd1d9dc11565918e204f98dcec7d6b47d2 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 21 Feb 2016 00:54:51 +0100 Subject: [PATCH] Moved getExtension back to FileUtil --- src/dorkbox/systemTray/ImageUtil.java | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/dorkbox/systemTray/ImageUtil.java b/src/dorkbox/systemTray/ImageUtil.java index 3a29af2..4c16bb3 100644 --- a/src/dorkbox/systemTray/ImageUtil.java +++ b/src/dorkbox/systemTray/ImageUtil.java @@ -1,5 +1,21 @@ +/* + * Copyright 2016 dorkbox, llc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dorkbox.systemTray; +import dorkbox.util.FileUtil; import dorkbox.util.LocationResolver; import dorkbox.util.OS; @@ -18,13 +34,10 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -/** - * - */ public class ImageUtil { - private static final File TEMP_DIR = new File(System.getProperty("java.io.tmpdir")); + public static final File TEMP_DIR = new File(System.getProperty("java.io.tmpdir")); private static MessageDigest digest; @@ -159,12 +172,12 @@ class ImageUtil { // can be wimpy, only one at a time String hash = hashName(bytes); - String extension = ""; - int dot = cacheName.lastIndexOf('.'); - if (dot > -1) { - extension = cacheName.substring(dot + 1); + String extension = FileUtil.getExtension(cacheName); + if (extension == null) { + extension = ""; } + newFile = new File(TEMP_DIR, "SYSTRAY_" + hash + '.' + extension).getAbsoluteFile(); if (SystemTray.isKDE) { // KDE is unique per run, so this prevents buildup