//# 0 errors, 256 messages
//#
/*
    //#FileResourceManager.java:1:1: class: com.dmdirc.util.resourcemanager.FileResourceManager
    //#FileResourceManager.java:1:1: method: com.dmdirc.util.resourcemanager.FileResourceManager.com.dmdirc.util.resourcemanager.FileResourceManager__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.util.resourcemanager;

import com.dmdirc.logger.ErrorLevel;
import com.dmdirc.logger.Logger;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Provides an easy way to access files inside a project.
 */
public final class FileResourceManager extends ResourceManager {
    
    /** Base path for the project. */
    private final String basePath;
    
    /**
     * Creates a new instance of FileResourceManager.
     * 
     * @param basePath Base path for the resource manager
     */
    protected FileResourceManager(final String basePath) {
        super();
    //#FileResourceManager.java:53: method: void com.dmdirc.util.resourcemanager.FileResourceManager.com.dmdirc.util.resourcemanager.FileResourceManager(String)
    //#input(void com.dmdirc.util.resourcemanager.FileResourceManager(String)): basePath
    //#input(void com.dmdirc.util.resourcemanager.FileResourceManager(String)): this
    //#output(void com.dmdirc.util.resourcemanager.FileResourceManager(String)): this.basePath
    //#post(void com.dmdirc.util.resourcemanager.FileResourceManager(String)): this.basePath == basePath
    //#post(void com.dmdirc.util.resourcemanager.FileResourceManager(String)): init'ed(this.basePath)
        
        this.basePath = basePath;
    }
    //#FileResourceManager.java:56: end of method: void com.dmdirc.util.resourcemanager.FileResourceManager.com.dmdirc.util.resourcemanager.FileResourceManager(String)
    
    /** {@inheritDoc} */
    @Override
    public boolean resourceExists(final String resource) {
        final File file;
        
        if (resource.startsWith(basePath)) {
    //#FileResourceManager.java:63: method: bool com.dmdirc.util.resourcemanager.FileResourceManager.resourceExists(String)
    //#input(bool resourceExists(String)): resource
    //#input(bool resourceExists(String)): this
    //#input(bool resourceExists(String)): this.basePath
    //#output(bool resourceExists(String)): return_value
    //#pre[1] (bool resourceExists(String)): resource != null
    //#post(bool resourceExists(String)): init'ed(return_value)
    //#test_vector(bool resourceExists(String)): java.lang.String:startsWith(...)@63: {0}, {1}
            file = new File(resource);
        } else {
            file = new File(basePath, resource);
        }
        
        return file.exists() && !file.isDirectory();
    //#FileResourceManager.java:69: end of method: bool com.dmdirc.util.resourcemanager.FileResourceManager.resourceExists(String)
    }
    
    /** {@inheritDoc} */
    @Override
    public byte[] getResourceBytes(final String resource) {
        FileInputStream inputStream;
        final File file;
        
        if (resource.startsWith(basePath)) {
    //#FileResourceManager.java:78: method: byte[] com.dmdirc.util.resourcemanager.FileResourceManager.getResourceBytes(String)
    //#input(byte[] getResourceBytes(String)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(byte[] getResourceBytes(String)): resource
    //#input(byte[] getResourceBytes(String)): this
    //#input(byte[] getResourceBytes(String)): this.basePath
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#3) num objects
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#3).length
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#4) num objects
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#4).length
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#5) num objects
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#5).length
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#7) num objects
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#7).length
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#8) num objects
    //#output(byte[] getResourceBytes(String)): new byte[](getResourceBytes#8).length
    //#output(byte[] getResourceBytes(String)): return_value
    //#new obj(byte[] getResourceBytes(String)): new byte[](getResourceBytes#3)
    //#new obj(byte[] getResourceBytes(String)): new byte[](getResourceBytes#4)
    //#new obj(byte[] getResourceBytes(String)): new byte[](getResourceBytes#5)
    //#new obj(byte[] getResourceBytes(String)): new byte[](getResourceBytes#7)
    //#new obj(byte[] getResourceBytes(String)): new byte[](getResourceBytes#8)
    //#pre[1] (byte[] getResourceBytes(String)): resource != null
    //#presumption(byte[] getResourceBytes(String)): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#presumption(byte[] getResourceBytes(String)): java.io.File:length(...)@92 >= 0
    //#post(byte[] getResourceBytes(String)): return_value in Addr_Set{&new byte[](getResourceBytes#5),&new byte[](getResourceBytes#8),&new byte[](getResourceBytes#7),&new byte[](getResourceBytes#4),&new byte[](getResourceBytes#3)}
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#3) num objects <= 1
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#3).length == 0
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#4) num objects <= 1
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#4).length == 0
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#5) num objects <= 1
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#5).length <= 18_446_744_073_709_551_615
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#7) num objects <= 1
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#7).length == 0
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#8) num objects <= 1
    //#post(byte[] getResourceBytes(String)): new byte[](getResourceBytes#8).length == 0
    //#test_vector(byte[] getResourceBytes(String)): java.io.File:exists(...)@84: {1}, {0}
    //#test_vector(byte[] getResourceBytes(String)): java.io.File:isDirectory(...)@88: {0}, {1}
    //#test_vector(byte[] getResourceBytes(String)): java.lang.String:startsWith(...)@78: {0}, {1}
            file = new File(resource);
        } else {
            file = new File(basePath, resource);
        }
        
        if (!file.exists()) {
            return new byte[0];
        }
        
        if (file.isDirectory()) {
            return new byte[0];
        }
        
        final byte[] bytes = new byte[(int) file.length()];
        
        try {
            inputStream = new FileInputStream(file);
        } catch (FileNotFoundException ex) {
            return new byte[0];
        }
        
        try {
            inputStream.read(bytes);
        } catch (IOException ex) {
            return new byte[0];
        }
        
        try {
            inputStream.close();
        } catch (IOException ex) {
            Logger.userError(ErrorLevel.LOW, "Unable to close stream");
    //#FileResourceManager.java:109: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.util.resourcemanager.FileResourceManager
    //#    method: byte[] getResourceBytes(String)
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String)
        }
        
        return bytes;
    //#FileResourceManager.java:112: end of method: byte[] com.dmdirc.util.resourcemanager.FileResourceManager.getResourceBytes(String)
    }
    
    /** {@inheritDoc} */
    @Override
    public InputStream getResourceInputStream(final String resource) {
        final File file;
        
        if (resource.startsWith(basePath)) {
    //#FileResourceManager.java:120: method: InputStream com.dmdirc.util.resourcemanager.FileResourceManager.getResourceInputStream(String)
    //#input(InputStream getResourceInputStream(String)): resource
    //#input(InputStream getResourceInputStream(String)): this
    //#input(InputStream getResourceInputStream(String)): this.basePath
    //#output(InputStream getResourceInputStream(String)): new FileInputStream(getResourceInputStream#3) num objects
    //#output(InputStream getResourceInputStream(String)): return_value
    //#new obj(InputStream getResourceInputStream(String)): new FileInputStream(getResourceInputStream#3)
    //#pre[1] (InputStream getResourceInputStream(String)): resource != null
    //#post(InputStream getResourceInputStream(String)): return_value in Addr_Set{null,&new FileInputStream(getResourceInputStream#3)}
    //#post(InputStream getResourceInputStream(String)): new FileInputStream(getResourceInputStream#3) num objects <= 1
    //#test_vector(InputStream getResourceInputStream(String)): java.io.File:exists(...)@126: {1}, {0}
    //#test_vector(InputStream getResourceInputStream(String)): java.io.File:isDirectory(...)@130: {0}, {1}
    //#test_vector(InputStream getResourceInputStream(String)): java.lang.String:startsWith(...)@120: {0}, {1}
            file = new File(resource);
        } else {
            file = new File(basePath, resource);
        }
        
        if (!file.exists()) {
            return null;
        }
        
        if (file.isDirectory()) {
            return null;
        }
        
        try {
            return new FileInputStream(file);
        } catch (FileNotFoundException ex) {
            return null;
    //#FileResourceManager.java:137: end of method: InputStream com.dmdirc.util.resourcemanager.FileResourceManager.getResourceInputStream(String)
        }
    }
    
    /** {@inheritDoc} */
    @Override
    public Map<String, byte[]> getResourcesEndingWithAsBytes(
            final String resourcesSuffix) {
        final List<File> files = getFileListing(new File(basePath));
    //#FileResourceManager.java:145: method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesEndingWithAsBytes(String)
    //#input(Map getResourcesEndingWithAsBytes(String)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(Map getResourcesEndingWithAsBytes(String)): resourcesSuffix
    //#input(Map getResourcesEndingWithAsBytes(String)): this
    //#input(Map getResourcesEndingWithAsBytes(String)): this.basePath
    //#output(Map getResourcesEndingWithAsBytes(String)): new HashMap(getResourcesEndingWithAsBytes#2) num objects
    //#output(Map getResourcesEndingWithAsBytes(String)): return_value
    //#new obj(Map getResourcesEndingWithAsBytes(String)): new HashMap(getResourcesEndingWithAsBytes#2)
    //#pre[3] (Map getResourcesEndingWithAsBytes(String)): (soft) this.basePath != null
    //#presumption(Map getResourcesEndingWithAsBytes(String)): java.io.File:getPath(...)@149 != null
    //#presumption(Map getResourcesEndingWithAsBytes(String)): java.io.File:getPath(...)@149 != null
    //#presumption(Map getResourcesEndingWithAsBytes(String)): java.util.Iterator:next(...)@148 != null
    //#post(Map getResourcesEndingWithAsBytes(String)): return_value == &new HashMap(getResourcesEndingWithAsBytes#2)
    //#post(Map getResourcesEndingWithAsBytes(String)): new HashMap(getResourcesEndingWithAsBytes#2) num objects == 1
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File:length
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream:read
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream:close
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.Arrays:asList
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.io.File:isFile
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.List:add
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:getFileListing
    //#unanalyzed(Map getResourcesEndingWithAsBytes(String)): Effects-of-calling:java.util.List:addAll
    //#test_vector(Map getResourcesEndingWithAsBytes(String)): java.lang.String:endsWith(...)@151: {0}, {1}
    //#test_vector(Map getResourcesEndingWithAsBytes(String)): java.util.Iterator:hasNext(...)@148: {0}, {1}
        final Map<String, byte[]> resources = new HashMap<String, byte[]>();
        
        for (File file : files) {
            final String path = file.getPath().substring(basePath.length(),
                    file.getPath().length());
            if (path.endsWith(resourcesSuffix)) {
                resources.put(path, getResourceBytes(path));
            }
        }
        
        return resources;
    //#FileResourceManager.java:156: end of method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesEndingWithAsBytes(String)
    }
    
    /** {@inheritDoc} */
    @Override
    public Map<String, byte[]> getResourcesStartingWithAsBytes(
            final String resourcesPrefix) {
        final List<File> files = getFileListing(new File(basePath));
    //#FileResourceManager.java:163: method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWithAsBytes(String)
    //#input(Map getResourcesStartingWithAsBytes(String)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(Map getResourcesStartingWithAsBytes(String)): resourcesPrefix
    //#input(Map getResourcesStartingWithAsBytes(String)): this
    //#input(Map getResourcesStartingWithAsBytes(String)): this.basePath
    //#output(Map getResourcesStartingWithAsBytes(String)): new HashMap(getResourcesStartingWithAsBytes#2) num objects
    //#output(Map getResourcesStartingWithAsBytes(String)): return_value
    //#new obj(Map getResourcesStartingWithAsBytes(String)): new HashMap(getResourcesStartingWithAsBytes#2)
    //#pre[3] (Map getResourcesStartingWithAsBytes(String)): (soft) this.basePath != null
    //#presumption(Map getResourcesStartingWithAsBytes(String)): java.io.File:getPath(...)@167 != null
    //#presumption(Map getResourcesStartingWithAsBytes(String)): java.io.File:getPath(...)@167 != null
    //#presumption(Map getResourcesStartingWithAsBytes(String)): java.util.Iterator:next(...)@166 != null
    //#post(Map getResourcesStartingWithAsBytes(String)): return_value == &new HashMap(getResourcesStartingWithAsBytes#2)
    //#post(Map getResourcesStartingWithAsBytes(String)): new HashMap(getResourcesStartingWithAsBytes#2) num objects == 1
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File:length
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream:read
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.FileInputStream:close
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.Arrays:asList
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.io.File:isFile
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.List:add
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:getFileListing
    //#unanalyzed(Map getResourcesStartingWithAsBytes(String)): Effects-of-calling:java.util.List:addAll
    //#test_vector(Map getResourcesStartingWithAsBytes(String)): java.lang.String:startsWith(...)@169: {0}, {1}
    //#test_vector(Map getResourcesStartingWithAsBytes(String)): java.util.Iterator:hasNext(...)@166: {0}, {1}
        final Map<String, byte[]> resources = new HashMap<String, byte[]>();
        
        for (File file : files) {
            final String path = file.getPath().substring(basePath.length(),
                    file.getPath().length());
            if (path.startsWith(resourcesPrefix)) {
                resources.put(path, getResourceBytes(path));
            }
        }
        
        return resources;
    //#FileResourceManager.java:174: end of method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWithAsBytes(String)
    }
    
    /** {@inheritDoc} */
    @Override
    public Map<String, InputStream> getResourcesStartingWithAsInputStreams(
            final String resourcesPrefix) {
        final List<File> files = getFileListing(new File(basePath));
    //#FileResourceManager.java:181: method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWithAsInputStreams(String)
    //#input(Map getResourcesStartingWithAsInputStreams(String)): resourcesPrefix
    //#input(Map getResourcesStartingWithAsInputStreams(String)): this
    //#input(Map getResourcesStartingWithAsInputStreams(String)): this.basePath
    //#output(Map getResourcesStartingWithAsInputStreams(String)): new HashMap(getResourcesStartingWithAsInputStreams#2) num objects
    //#output(Map getResourcesStartingWithAsInputStreams(String)): return_value
    //#new obj(Map getResourcesStartingWithAsInputStreams(String)): new HashMap(getResourcesStartingWithAsInputStreams#2)
    //#pre[3] (Map getResourcesStartingWithAsInputStreams(String)): (soft) this.basePath != null
    //#presumption(Map getResourcesStartingWithAsInputStreams(String)): java.io.File:getPath(...)@185 != null
    //#presumption(Map getResourcesStartingWithAsInputStreams(String)): java.io.File:getPath(...)@185 != null
    //#presumption(Map getResourcesStartingWithAsInputStreams(String)): java.util.Iterator:next(...)@184 != null
    //#post(Map getResourcesStartingWithAsInputStreams(String)): return_value == &new HashMap(getResourcesStartingWithAsInputStreams#2)
    //#post(Map getResourcesStartingWithAsInputStreams(String)): new HashMap(getResourcesStartingWithAsInputStreams#2) num objects == 1
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.lang.String:startsWith
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.File
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.File:exists
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.FileInputStream
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.Arrays:asList
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.io.File:isFile
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.List:add
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:getFileListing
    //#unanalyzed(Map getResourcesStartingWithAsInputStreams(String)): Effects-of-calling:java.util.List:addAll
    //#test_vector(Map getResourcesStartingWithAsInputStreams(String)): java.lang.String:startsWith(...)@187: {0}, {1}
    //#test_vector(Map getResourcesStartingWithAsInputStreams(String)): java.util.Iterator:hasNext(...)@184: {0}, {1}
        final Map<String, InputStream> resources = new HashMap<String, InputStream>();
        
        for (File file : files) {
            final String path = file.getPath().substring(basePath.length(),
                    file.getPath().length());
            if (path.startsWith(resourcesPrefix)) {
                resources.put(path, getResourceInputStream(path));
            }
        }
        
        return resources;
    //#FileResourceManager.java:192: end of method: Map com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWithAsInputStreams(String)
    }
    
    /** {@inheritDoc} */
    @Override
    public List<String> getResourcesStartingWith(final String resourcesPrefix) {
        final List<File> files = getFileListing(new File(basePath));
    //#FileResourceManager.java:198: method: List com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWith(String)
    //#input(List getResourcesStartingWith(String)): resourcesPrefix
    //#input(List getResourcesStartingWith(String)): this
    //#input(List getResourcesStartingWith(String)): this.basePath
    //#output(List getResourcesStartingWith(String)): new ArrayList(getResourcesStartingWith#2) num objects
    //#output(List getResourcesStartingWith(String)): return_value
    //#new obj(List getResourcesStartingWith(String)): new ArrayList(getResourcesStartingWith#2)
    //#pre[3] (List getResourcesStartingWith(String)): (soft) this.basePath != null
    //#presumption(List getResourcesStartingWith(String)): java.io.File:getPath(...)@202 != null
    //#presumption(List getResourcesStartingWith(String)): java.io.File:getPath(...)@202 != null
    //#presumption(List getResourcesStartingWith(String)): java.util.Iterator:next(...)@201 != null
    //#post(List getResourcesStartingWith(String)): return_value == &new ArrayList(getResourcesStartingWith#2)
    //#post(List getResourcesStartingWith(String)): new ArrayList(getResourcesStartingWith#2) num objects == 1
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.Arrays:asList
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.io.File:isFile
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.List:add
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:getFileListing
    //#unanalyzed(List getResourcesStartingWith(String)): Effects-of-calling:java.util.List:addAll
    //#test_vector(List getResourcesStartingWith(String)): java.lang.String:startsWith(...)@204: {0}, {1}
    //#test_vector(List getResourcesStartingWith(String)): java.util.Iterator:hasNext(...)@201: {0}, {1}
        final List<String> resources = new ArrayList<String>();
        
        for (File file : files) {
            final String path = file.getPath().substring(basePath.length(),
                    file.getPath().length());
            if (path.startsWith(resourcesPrefix)) {
                resources.add(path);
            }
        }
        
        return resources;
    //#FileResourceManager.java:209: end of method: List com.dmdirc.util.resourcemanager.FileResourceManager.getResourcesStartingWith(String)
    }
    
    /**
     * Returns a resursive listing of a directory tree.
     *
     * @param startingDirectory Starting directory for the file listing
     *
     * @return Recursive directory listing
     */
    private static List<File> getFileListing(final File startingDirectory) {
        final List<File> result = new ArrayList<File>();
    //#FileResourceManager.java:220: method: List com.dmdirc.util.resourcemanager.FileResourceManager.getFileListing(File)
    //#input(List getFileListing(File)): startingDirectory
    //#output(List getFileListing(File)): new ArrayList(getFileListing#1) num objects
    //#output(List getFileListing(File)): return_value
    //#new obj(List getFileListing(File)): new ArrayList(getFileListing#1)
    //#pre[1] (List getFileListing(File)): startingDirectory != null
    //#presumption(List getFileListing(File)): java.util.Arrays:asList(...)@226 != null
    //#presumption(List getFileListing(File)): java.util.Iterator:next(...)@227 != null
    //#post(List getFileListing(File)): return_value == &new ArrayList(getFileListing#1)
    //#post(List getFileListing(File)): new ArrayList(getFileListing#1) num objects == 1
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.io.File:listFiles
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.Arrays:asList
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.io.File:isFile
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.List:add
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:getFileListing
    //#unanalyzed(List getFileListing(File)): Effects-of-calling:java.util.List:addAll
    //#test_vector(List getFileListing(File)): java.io.File:isFile(...)@228: {0}, {1}
    //#test_vector(List getFileListing(File)): java.io.File:listFiles(...)@222: Inverse{null}, Addr_Set{null}
    //#test_vector(List getFileListing(File)): java.util.Iterator:hasNext(...)@227: {0}, {1}
        
        if (startingDirectory.listFiles() == null) {
            return result;
        }
        
        final List<File> files = Arrays.asList(startingDirectory.listFiles());
        for (File file : files) {
            if (file.isFile()) {
                result.add(file);
            } else {
                result.addAll(getFileListing(file));
            }
        }
        return result;
    //#FileResourceManager.java:234: end of method: List com.dmdirc.util.resourcemanager.FileResourceManager.getFileListing(File)
    }
}
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Descendant_Table[com/dmdirc/util/resourcemanager/FileResourceManager]
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResource(Ljava/lang/String;Ljava/lang/String;Z)Z
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResources(Ljava/lang/String;Ljava/lang/String;)V
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResources(Ljava/lang/String;Ljava/lang/String;Z)V
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourceBytes(Ljava/lang/String;)[B
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourceInputStream(Ljava/lang/String;)Ljava/io/InputStream;
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesEndingWithAsBytes(Ljava/lang/String;)Ljava/util/Map;
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWith(Ljava/lang/String;)Ljava/util/List;
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWithAsBytes(Ljava/lang/String;)Ljava/util/Map;
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWithAsInputStreams(Ljava/lang/String;)Ljava/util/Map;
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.resourceExists(Ljava/lang/String;)Z
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.resourceToFile([BLjava/io/File;)V
    //#output(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): com/dmdirc/util/resourcemanager/ResourceManager.__Descendant_Table[com/dmdirc/util/resourcemanager/FileResourceManager]
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Descendant_Table[com/dmdirc/util/resourcemanager/FileResourceManager] == &__Dispatch_Table
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): com/dmdirc/util/resourcemanager/ResourceManager.__Descendant_Table[com/dmdirc/util/resourcemanager/FileResourceManager] == &__Dispatch_Table
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResource(Ljava/lang/String;Ljava/lang/String;Z)Z == &com/dmdirc/util/resourcemanager/ResourceManager.extractResource
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResources(Ljava/lang/String;Ljava/lang/String;)V == &com/dmdirc/util/resourcemanager/ResourceManager.extractResources
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.extractResources(Ljava/lang/String;Ljava/lang/String;Z)V == &com/dmdirc/util/resourcemanager/ResourceManager.extractResources
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourceBytes(Ljava/lang/String;)[B == &getResourceBytes
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourceInputStream(Ljava/lang/String;)Ljava/io/InputStream; == &getResourceInputStream
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesEndingWithAsBytes(Ljava/lang/String;)Ljava/util/Map; == &getResourcesEndingWithAsBytes
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWith(Ljava/lang/String;)Ljava/util/List; == &getResourcesStartingWith
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWithAsBytes(Ljava/lang/String;)Ljava/util/Map; == &getResourcesStartingWithAsBytes
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.getResourcesStartingWithAsInputStreams(Ljava/lang/String;)Ljava/util/Map; == &getResourcesStartingWithAsInputStreams
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.resourceExists(Ljava/lang/String;)Z == &resourceExists
    //#post(com.dmdirc.util.resourcemanager.FileResourceManager__static_init): __Dispatch_Table.resourceToFile([BLjava/io/File;)V == &com/dmdirc/util/resourcemanager/ResourceManager.resourceToFile
    //#FileResourceManager.java:: end of method: com.dmdirc.util.resourcemanager.FileResourceManager.com.dmdirc.util.resourcemanager.FileResourceManager__static_init
    //#FileResourceManager.java:: end of class: com.dmdirc.util.resourcemanager.FileResourceManager
