if (path.exists()) if (path.isFile()) result = path.delete(); if (s_log.isInfoEnabled()) s_log.info("deleteFile: successfully deleted file = " + path.getAbsolutePath()); s_log.info("deleteFile: failed to delete file = " + path.getAbsolutePath()); FileWrapper[] files = path.listFiles(); for (int i = 0; i < files.length; i++) result = result && path.delete();
if (file.isDirectory()) zipFileOs(os, file.listFiles()); try fis = new FileInputStream(file.getAbsolutePath()); os.putNextEntry(new ZipEntry(file.getPath())); _iou.copyBytes(fis, os);
/** * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#getInstalledTranslations() */ public Set<String> getInstalledTranslations() { HashSet<String> result = new HashSet<String>(); FileWrapper libDir = getSquirrelLibraryDir(); for (String filename : libDir.list()) { if (filename.startsWith("squirrel-sql_")) { result.add(filename); } } return result; }
private void verifyDirectory(FileWrapper fromDir, FileWrapper toDir) { if (!fromDir.isDirectory()) { throw new IllegalArgumentException("Expected fromDir(" + fromDir.getAbsolutePath() + ") to be a directory."); } if (!toDir.isDirectory()) { throw new IllegalArgumentException("Expected toDir(" + toDir.getAbsolutePath() + ") to be a directory."); } }
/** * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#checkDir(FileWrapper, java.lang.String) */ public FileWrapper checkDir(FileWrapper parent, String child) { FileWrapper dir = _fileWrapperFactory.create(parent, child); if (!dir.exists() && !dir.mkdir()) { s_log.error("checkDir: Failed to mkdir - " + dir.getAbsolutePath()); } return dir; }
downloadHttpUpdateFile(host, port, fileToGet, getDownloadsDir().getAbsolutePath(), -1, -1, proxySettings); FileWrapper releaseXmlFile = _fileWrapperFactory.create(filename); if (releaseXmlFile.exists())
/** * TODO: move to IOUtilities * * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#createZipFile(FileWrapper, FileWrapper[]) */ public void createZipFile(FileWrapper zipFile, FileWrapper... sourceFiles) throws FileNotFoundException, IOException { ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile.getAbsolutePath())); zipFileOs(os, sourceFiles); os.close(); }
if (!outputDirectory.isDirectory()) s_log.error("Output directory specified (" + outputDirectory.getAbsolutePath() + ") doesn't appear to be a directory"); return; try fis = new FileInputStream(zipFile.getAbsolutePath()); zis = new ZipInputStream(fis); ZipEntry zipEntry = zis.getNextEntry(); if (newFile.exists()) s_log.info("Deleting extraction file that already exists:" + newFile.getAbsolutePath()); newFile.delete(); fos = new FileOutputStream(newFile.getAbsolutePath()); byte[] buffer = new byte[ZIP_EXTRACTION_BUFFER_SIZE]; int n = 0;
try if (file.isFile() && file.exists()) lafs.put(className, file.toURI().toURL()); s_log.error("Error occured reading Look and Feel jar: " + file.getAbsolutePath(), ex); FileWrapper extraFile = fileWrapperFactory.create(extraLafsDir, ILAFConstants.USER_EXTRA_LAFS_PROPS_FILE); BufferedInputStream is = new BufferedInputStream(extraFile.getFileInputStream()); try try if (file.isFile() && file.exists()) lafs.put(className, file.toURI().toURL()); s_log.error("Error occured reading Look and Feel jar: " + file.getAbsolutePath(), ex);
if (!result.isDirectory()) if (result.exists()) s_log.error(dirName + " directory (" + result.getAbsolutePath() + ") doesn't appear to be a directory"); result.mkdir();
if (!file.exists()) file.mkdirs(); if (!file.isDirectory()) throw new IOException(s_stringMgr.getString("DefaultPlugin.error.cannotcreate", file.getAbsolutePath()));
IOException if (!from.exists()) s_log.error("Cannot copy from file (" + from.getAbsolutePath() + ") which doesn't appear to exist."); return; if (to.isDirectory()) toFile = getFile(to, from.getName()); s_log.debug("Copying from file (" + from.getAbsolutePath() + ") to file (" + toFile.getAbsolutePath() + ")"); if (toFile.exists()) s_log.info("File to be copied(" + from.getAbsolutePath() + ") has the same checksum(" + fromCheckSum + ") as the file to copy to (" + toFile.getAbsolutePath() + "). Skipping copy.");
if (oldAppPreferenceFile.exists()) if (oldAppPreferenceFile.lastModified() > newUserPreferenceFile.lastModified()) + oldAppPreferenceFile.getAbsolutePath() + " as the source for preferences - will save " + "them to " + newUserPreferenceFile.getAbsolutePath()); + newUserPreferenceFile.getAbsolutePath() + " is newer " + "than " + oldAppPreferenceFile.getAbsolutePath() + ": migration will be skipped"); + oldAppPreferenceFile.getAbsolutePath() + " does not " + "exist! Please remove -DmigratePreferences from the " + "launch script, or fix -DoldSquirrelLocation to "
_prefs.setThemePackDirectory(themePackDir.getAbsolutePath()); if (!themePackDir.exists()) themePackDir.mkdirs();
public static XMLBeanReader createHibernateConfigsReader(HibernatePlugin plugin) throws IOException, XMLException { XMLBeanReader reader = new XMLBeanReader(); FileWrapper pluginUserSettingsFolder = plugin.getPluginUserSettingsFolder(); FileWrapper xmlFile = getXmlFile(pluginUserSettingsFolder); if (false == xmlFile.exists()) { return null; } reader.load(xmlFile, plugin.getClass().getClassLoader()); return reader; }
/** * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#copyDir( * net.sourceforge.squirrel_sql.fw.util.FileWrapper, * java.lang.String, boolean, net.sourceforge.squirrel_sql.fw.util.FileWrapper) */ @Override public void moveFiles(FileWrapper fromDir, String filePattern, boolean matchPattern, FileWrapper toDir) throws FileNotFoundException, IOException { if (StringUtils.isEmpty(filePattern)) { throw new IllegalArgumentException("filePattern arg cannot be empty or null"); } if (!fromDir.isDirectory()) { throw new IllegalArgumentException("Expected fromDir(" + fromDir.getAbsolutePath() + ") to be a directory."); } if (!toDir.isDirectory()) { throw new IllegalArgumentException("Expected toDir(" + toDir.getAbsolutePath() + ") to be a directory."); } List<FileWrapper> filesToMove = getFilterFileList(fromDir, filePattern, matchPattern); for (FileWrapper file : filesToMove) { copyFile(file, toDir); if (s_log.isDebugEnabled()) { s_log.debug("moveFiles: Attempting to delete file "+file.getAbsolutePath()); } if (file.delete()) { s_log.error("moveFiles: Unable to delete file "+file.getAbsolutePath()); } } }
+ File.separator; FileWrapper file = fileWrapperFactory.create(name); if (!file.exists()) file.mkdirs(); if (!file.isDirectory())
/** * Save preferences to disk. * * @param prefsFile * File to save preferences to. */ private void savePrefs(FileWrapper prefsFile) throws IOException, XMLException { _settingsCache.save(prefsFile.getPath()); }
/** * @see net.sourceforge.squirrel_sql.plugins.dbdiff.IScriptFileManager#cleanupScriptFiles() */ public void cleanupScriptFiles() { for (final String scriptFile : scriptFiles) { final FileWrapper fileWrapper = fileWrapperFactory.create(scriptFile); if (fileWrapper.exists()) { if (s_log.isDebugEnabled()) { s_log.debug("Attempting to delete previously created temporary script file: " + scriptFile); } fileWrapper.delete(); } else { if (s_log.isDebugEnabled()) { s_log.debug("Previously created temporary script file did not exist: " + scriptFile); } } } }