// Path: src/main/java/ninja/eivind/hotsreplayuploader/files/tempwatcher/BattleLobbyTempDirectories.java
// public class BattleLobbyTempDirectories {
// 
//     private final File root;
//     private final File remainder;
// 
//     public BattleLobbyTempDirectories(File root, File remainder) {
//         this.root = root;
//         this.remainder = remainder;
//     }
// 
//     public File getRoot() {
//         return root;
//     }
// 
//     public File getRemainder() {
//         return remainder;
//     }
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/utils/SimpleHttpClient.java
// public class SimpleHttpClient {
// 
//     public static final String SPACE = "%20";
//     private static final Logger LOG = LoggerFactory.getLogger(SimpleHttpClient.class);
// 
//     /**
//      * Encodes a given String url into a valid URI if possible
//      * Method should be updated as required to make sure any valid String url that can be pasted into an address bar
//      * will fit into a URI object
//      *
//      * @param url the url to encode
//      * @return a newly built URI if at all possible
//      */
//     public static URI encode(final String url) {
//         return URI.create(url.replaceAll(" ", SPACE));
//     }
// 
//     public String simpleRequest(final String target) throws IOException {
//         return simpleRequest(encode(target));
//     }
// 
//     public String simpleRequest(final URI uri) throws IOException {
//         return simpleRequest(uri.toURL());
//     }
// 
//     public String simpleRequest(final URL url) throws IOException {
//         LOG.info("Opening connection to " + url);
//         final InputStream inputStream = url.openStream();
//         return IOUtils.readInputStream(inputStream);
//     }
// }


import ninja.eivind.hotsreplayuploader.files.tempwatcher.BattleLobbyTempDirectories;
import ninja.eivind.hotsreplayuploader.utils.SimpleHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
                    // cut the contents of line, after "...$HOME/" up to last symbol "
                    // XDG_DOCUMENTS_DIR="$HOME/Documents"
                    //                          ^_______^
                    xdgDocsPath = line.substring(lineStart.length(), line.length() - 1);
                    break;
                }
            }
        } catch (IOException ioe) {
            LOG.error("Failed to read XDG user-dirs config file " + file.toString());
        } catch (StringIndexOutOfBoundsException e) {
            LOG.error("Error parsing XDG user-dirs config file " + file.toString());
        }
        return xdgDocsPath != null ? xdgDocsPath : XDG_DEFAULT_DOCS_PATH;
    }

    @Override
    public File getHotSHome() {
        final File file = new File(USER_HOME, "Heroes of the Storm/Accounts/");
        if (file.exists()) {
            return file;
        } else {
            String docsPath = getXDGDocumentsPath();
            return new File(USER_HOME, docsPath + "/Heroes of the Storm/Accounts/");
        }
    }

    @Override
    public void browse(final String uri) {
        try {
            if (Desktop.isDesktopSupported()) {
// Path: src/main/java/ninja/eivind/hotsreplayuploader/files/tempwatcher/BattleLobbyTempDirectories.java
// public class BattleLobbyTempDirectories {
// 
//     private final File root;
//     private final File remainder;
// 
//     public BattleLobbyTempDirectories(File root, File remainder) {
//         this.root = root;
//         this.remainder = remainder;
//     }
// 
//     public File getRoot() {
//         return root;
//     }
// 
//     public File getRemainder() {
//         return remainder;
//     }
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/utils/SimpleHttpClient.java
// public class SimpleHttpClient {
// 
//     public static final String SPACE = "%20";
//     private static final Logger LOG = LoggerFactory.getLogger(SimpleHttpClient.class);
// 
//     /**
//      * Encodes a given String url into a valid URI if possible
//      * Method should be updated as required to make sure any valid String url that can be pasted into an address bar
//      * will fit into a URI object
//      *
//      * @param url the url to encode
//      * @return a newly built URI if at all possible
//      */
//     public static URI encode(final String url) {
//         return URI.create(url.replaceAll(" ", SPACE));
//     }
// 
//     public String simpleRequest(final String target) throws IOException {
//         return simpleRequest(encode(target));
//     }
// 
//     public String simpleRequest(final URI uri) throws IOException {
//         return simpleRequest(uri.toURL());
//     }
// 
//     public String simpleRequest(final URL url) throws IOException {
//         LOG.info("Opening connection to " + url);
//         final InputStream inputStream = url.openStream();
//         return IOUtils.readInputStream(inputStream);
//     }
// }


// Path: src/main/java/ninja/eivind/hotsreplayuploader/services/platform/LinuxService.java
import ninja.eivind.hotsreplayuploader.files.tempwatcher.BattleLobbyTempDirectories;
import ninja.eivind.hotsreplayuploader.utils.SimpleHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;

                    // cut the contents of line, after "...$HOME/" up to last symbol "
                    // XDG_DOCUMENTS_DIR="$HOME/Documents"
                    //                          ^_______^
                    xdgDocsPath = line.substring(lineStart.length(), line.length() - 1);
                    break;
                }
            }
        } catch (IOException ioe) {
            LOG.error("Failed to read XDG user-dirs config file " + file.toString());
        } catch (StringIndexOutOfBoundsException e) {
            LOG.error("Error parsing XDG user-dirs config file " + file.toString());
        }
        return xdgDocsPath != null ? xdgDocsPath : XDG_DEFAULT_DOCS_PATH;
    }

    @Override
    public File getHotSHome() {
        final File file = new File(USER_HOME, "Heroes of the Storm/Accounts/");
        if (file.exists()) {
            return file;
        } else {
            String docsPath = getXDGDocumentsPath();
            return new File(USER_HOME, docsPath + "/Heroes of the Storm/Accounts/");
        }
    }

    @Override
    public void browse(final String uri) {
        try {
            if (Desktop.isDesktopSupported()) {
                desktop.browse(SimpleHttpClient.encode(uri));