This repository contains MadHelix itself, along with compiled libraries with its dependencies.

[[ 🗃 ^ZEkyo madhelix ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/ZEkyo

SSH: git clone USERNAME@vervis.peers.community:ZEkyo

Branches

Tags

v0.0.1 :: src / org / ultrasonicmadness / ultrasonichelix / utils /

PathUtils.java

/*
 * UltrasonicHelix is a Java Swing-based GUI frontend for SoundHelix.
 * Copyright (C) 2017 UltrasonicMadness
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.ultrasonicmadness.ultrasonichelix.utils;

import java.io.File;
import java.util.ArrayList;

public class PathUtils {
    // Get path to UltrasonicHelix.jar
    public static String getMainJarPath() {
        String mainJarPath = new File(
            System.getProperty("java.class.path")
        ).getAbsolutePath();
        
        return mainJarPath;
    }

    // Get path to directory containing UltrasonicHelix.jar
    public static String getParentDirPath() {
        String parentDirPath = new File(getMainJarPath()).getParent();
        return parentDirPath;
    }
    
    // Get path to directory containing SoundHelix xml files.
    public static String getStylesDirPath() {
        String stylesDirPath = getParentDirPath() + File.separator + "styles";
        return stylesDirPath;
    }
    
    // Get list of available SoundHelix styles
    public static String[] getStyles() {
        ArrayList<String> styleList = new ArrayList<>();
        String[] fullFileList = new File(getStylesDirPath()).list();
        
        try {
            for (String fileName : fullFileList) {
                // Only return files ending with the extension XML
                if (fileName.substring(fileName.length() - 4).equals(".xml")) {
                    // Remove .xml from the end of the style names
                    styleList.add(
                        fileName.substring(0, fileName.length() - 4)
                    );
                }
            }
        } catch (Exception e) {
            System.err.println("Error loading styles");
        }
        
        // Convert ArrayList to standard array.
        return styleList.toArray(new String[styleList.size()]);
    }
}

[See repo JSON]