Search in sources :

Example 1 with BackupInputStream

use of com.mucommander.io.backup.BackupInputStream in project mucommander by mucommander.

the class CommandManager method loadAssociations.

/**
 * Loads the custom associations XML File.
 * <p>
 * The command files will be loaded as a <i>backed-up file</i> (see {@link BackupInputStream}).
 * Its format is described {@link AssociationsXmlConstants here}.
 * </p>
 * @throws IOException if an IO error occurs.
 * @see                #writeAssociations()
 * @see                #getAssociationFile()
 * @see                #setAssociationFile(String)
 */
public static void loadAssociations() throws IOException, CommandException {
    AbstractFile file = getAssociationFile();
    LOGGER.debug("Loading associations from file: " + file.getAbsolutePath());
    // Tries to load the associations file.
    // Associations are not considered to be modified by this.
    InputStream in = null;
    try {
        AssociationReader.read(in = new BackupInputStream(file), new AssociationFactory());
    } finally {
        wereAssociationsModified = false;
        // Makes sure the input stream is closed.
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            // Ignores this.
            }
        }
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) BackupInputStream(com.mucommander.io.backup.BackupInputStream) InputStream(java.io.InputStream) BackupInputStream(com.mucommander.io.backup.BackupInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with BackupInputStream

use of com.mucommander.io.backup.BackupInputStream in project mucommander by mucommander.

the class BookmarkManager method loadBookmarks.

// - Bookmarks loading -----------------------------------------------------
// -------------------------------------------------------------------------
/**
 * Loads all available bookmarks.
 * @throws Exception if an error occurs.
 */
public static synchronized void loadBookmarks() throws Exception {
    InputStream in;
    // Parse the bookmarks file
    in = null;
    isLoading = true;
    try {
        readBookmarks(in = new BackupInputStream(getBookmarksFile()), new Loader());
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
        isLoading = false;
    }
}
Also used : BackupInputStream(com.mucommander.io.backup.BackupInputStream) BackupInputStream(com.mucommander.io.backup.BackupInputStream)

Example 3 with BackupInputStream

use of com.mucommander.io.backup.BackupInputStream in project mucommander by mucommander.

the class ShellHistoryManager method loadHistory.

/**
 * Loads the shell history.
 * @throws Exception if an error occurs.
 */
public static void loadHistory() throws Exception {
    BackupInputStream in;
    in = null;
    try {
        ShellHistoryReader.read(in = new BackupInputStream(getHistoryFile()));
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e2) {
            }
        }
    }
}
Also used : BackupInputStream(com.mucommander.io.backup.BackupInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with BackupInputStream

use of com.mucommander.io.backup.BackupInputStream in project mucommander by mucommander.

the class CredentialsParser method parse.

/**
 * Parses the given XML credentials file. Should only be called by CredentialsManager.
 */
void parse(AbstractFile file) throws Exception {
    InputStream in;
    in = null;
    characters = new StringBuilder();
    try {
        SAXParserFactory.newInstance().newSAXParser().parse(in = new BackupInputStream(file), this);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (Exception e) {
            }
        }
    }
}
Also used : BackupInputStream(com.mucommander.io.backup.BackupInputStream) InputStream(java.io.InputStream) BackupInputStream(com.mucommander.io.backup.BackupInputStream) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 5 with BackupInputStream

use of com.mucommander.io.backup.BackupInputStream in project mucommander by mucommander.

the class CommandManager method loadCommands.

/**
 * Loads the custom commands XML File.
 * <p>
 * The command files will be loaded as a <i>backed-up file</i> (see {@link BackupInputStream}).
 * Its format is described {@link CommandsXmlConstants here}.
 * </p>
 * @throws IOException if an I/O error occurs.
 * @see                #writeCommands()
 * @see                #getCommandsFile()
 * @see                #setCommandFile(String)
 */
public static void loadCommands() throws IOException, CommandException {
    AbstractFile commandsFile = getCommandsFile();
    LOGGER.debug("Loading custom commands from: " + commandsFile.getAbsolutePath());
    // Commands are not considered to be modified by this.
    try (InputStream in = new BackupInputStream(commandsFile)) {
        CommandReader.read(in, new CommandManager());
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) BackupInputStream(com.mucommander.io.backup.BackupInputStream) InputStream(java.io.InputStream) BackupInputStream(com.mucommander.io.backup.BackupInputStream)

Aggregations

BackupInputStream (com.mucommander.io.backup.BackupInputStream)5 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 AbstractFile (com.mucommander.commons.file.AbstractFile)2 FileNotFoundException (java.io.FileNotFoundException)2 MalformedURLException (java.net.MalformedURLException)1 NoSuchElementException (java.util.NoSuchElementException)1 SAXException (org.xml.sax.SAXException)1