@Override public String normaliseFileName(String f_name) { return FileUtil.convertOSSpecificChars(f_name,false); }
public static void copyFileWithException( final File _source, final File _dest ) throws IOException{ copyFile( new FileInputStream( _source ), new FileOutputStream( _dest ) ); }
public FilterComparator() { String sep = File.separator; sUserPluginDir = FileUtil.getUserFile("plugins").toString(); if (!sUserPluginDir.endsWith(sep)) sUserPluginDir += sep; sAppPluginDir = FileUtil.getApplicationFile("plugins").toString(); if (!sAppPluginDir.endsWith(sep)) sAppPluginDir += sep; }
public boolean checkDefaultDir(File location, File[] default_dirs) { location = FileUtil.canonise(location); boolean subdir = this.getBoolean("default subdir", false); for (int i=0; i<default_dirs.length; i++) { if (subdir) { if (FileUtil.isAncestorOf(default_dirs[i], location)) {return true;} } else { if (default_dirs[i].equals(location)) {return true;} } } return false; }
protected static File getPropsIfNotPresent( String id, boolean use_shared ) { File user_plugin_dir = FileUtil.getUserFile("plugins"); File user_plugin = new File(user_plugin_dir, id); File user_props = new File( user_plugin, "plugin.properties" ); if ( user_props.exists()){ return( null ); } File shared_plugin_dir = FileUtil.getApplicationFile("plugins"); File shared_plugin = new File(shared_plugin_dir, id); File shared_props = new File(shared_plugin, "plugin.properties"); if ( shared_props.exists()){ return( null ); } if ( use_shared ){ FileUtil.mkdirs( shared_plugin ); return( shared_props ); }else{ FileUtil.mkdirs( user_plugin ); return( user_props ); } }
if (new_filename != null) {new_filename = FileUtil.convertOSSpecificChars(new_filename,false);} FileUtil.mkdirs(new_save_location.getParentFile()); if (FileUtil.isAncestorOf(old_file, new_save_location)) { if ( FileUtil.renameFile( old_file, new_save_location, false, ff, pl )){
@Override public File getFile() { return( FileUtil.getUserFile("filters.config")); }
public static void copyFileOrDirectory( File from_file_or_dir, File to_parent_dir ) throws IOException { if ( !from_file_or_dir.exists()){ throw( new IOException( "File '" + from_file_or_dir.toString() + "' doesn't exist" )); } if ( !to_parent_dir.exists()){ throw( new IOException( "File '" + to_parent_dir.toString() + "' doesn't exist" )); } if ( !to_parent_dir.isDirectory()){ throw( new IOException( "File '" + to_parent_dir.toString() + "' is not a directory" )); } if ( from_file_or_dir.isDirectory()){ File[] files = from_file_or_dir.listFiles(); File new_parent = new File( to_parent_dir, from_file_or_dir.getName()); FileUtil.mkdirs(new_parent); for (int i=0;i<files.length;i++){ File from_file = files[i]; copyFileOrDirectory( from_file, new_parent ); } }else{ File target = new File( to_parent_dir, from_file_or_dir.getName()); if ( !copyFile( from_file_or_dir, target )){ throw( new IOException( "File copy from " + from_file_or_dir + " to " + target + " failed" )); } } }
private static File getApplicationFile( String filename) { return FileUtil.getApplicationFile(filename); }
/** * * * @since 4.4.0.5 */ private void checkInstallID() { String storedInstallID = COConfigurationManager.getStringParameter("install.id", null); String installID = ""; File file = FileUtil.getApplicationFile("installer.log"); if (file != null) { try { String s = FileUtil.readFileAsString(file, 1024); String[] split = s.split("[\r\n]"); for (int i = 0; i < split.length; i++) { int posEquals = split[i].indexOf('='); if (posEquals > 0 && split[i].length() > posEquals + 1) { installID = split[i].substring(posEquals + 1); } } } catch (IOException e) { } } if (storedInstallID == null || !storedInstallID.equals(installID)) { COConfigurationManager.setParameter("install.id", installID); } }
if ( FileUtil.getUsableSpaceSupported()){ long usable = FileUtil.getUsableSpace( owner.getLinkedFile().getParentFile());
String magnet_uri = FileUtil.readFileAsString( active, 32000, "UTF-8" ); con.connect(); FileUtil.copyFile( con.getInputStream(), output_file );
Map map = BDecoder.decode( FileUtil.readFileAsByteArray( torrent_base )); logical_path.set( i, FileUtil.convertOSSpecificChars( logical_path.get(i), i < logical_path.size()-1));
share_dir = FileUtil.getUserFile( TORRENT_STORE ); FileUtil.mkdirs(share_dir);
FileUtil.copyFile(data, FileUtil.getUserFile("ipfilter.dl")); AEThread thread = new AEThread("reload ipfilters", true) { @Override
public static void importDownloadState( File source_dir, byte[] download_hash ) throws DownloadManagerException { String hash_str = ByteFormatter.encodeString( download_hash ); String state_file = hash_str + ".dat"; File target_state_file = new File( ACTIVE_DIR, state_file ); File source_state_file = new File( source_dir, state_file ); if ( !source_state_file.exists()){ throw( new DownloadManagerException( "Source state file missing: " + source_state_file )); } if ( target_state_file.exists()){ target_state_file.delete(); //throw( new DownloadManagerException( "Target state file already exists: " + target_state_file )); } if ( !FileUtil.copyFile( source_state_file, target_state_file )){ throw( new DownloadManagerException( "Failed to copy state file: " + source_state_file + " -> " + target_state_file )); } File source_state_dir = new File( source_dir, hash_str ); if ( source_state_dir.exists()){ try{ FileUtil.copyFileOrDirectory( source_state_dir, ACTIVE_DIR ); }catch( Throwable e ){ target_state_file.delete(); throw( new DownloadManagerException( "Failed to copy state dir: " + source_dir + " -> " + ACTIVE_DIR, e )); } } }
public static File getJarFileFromClass( Class cla ) { try{ String str = cla.getName(); str = str.replace( '.', '/' ) + ".class"; URL url = cla.getClassLoader().getResource( str ); if ( url != null ){ String url_str = url.toExternalForm(); if ( url_str.startsWith("jar:file:")){ File jar_file = FileUtil.getJarFileFromURL(url_str); if ( jar_file != null && jar_file.exists()){ return( jar_file ); } } } }catch( Throwable e ){ Debug.printStackTrace(e); } return( null ); }
tmp_dir = FileUtil.getUserFile( "tmp" ); FileUtil.recursiveDelete( file );
protected void importCustomization( Map map ) throws CustomizationException { try{ String name = new String((byte[])map.get( "name" ), "UTF-8" ); String version = new String((byte[])map.get( "version" ), "UTF-8" ); if ( !Constants.isValidVersionFormat( version )){ throw( new CustomizationException( "Invalid version specification: " + version )); } byte[] data = (byte[])map.get( "data" ); File user_dir = FileUtil.getUserFile("custom"); if ( !user_dir.exists()){ user_dir.mkdirs(); } File target = new File( user_dir, name + "_" + version + ".zip" ); if ( !target.exists()){ if ( !FileUtil.writeBytesAsFile2( target.getAbsolutePath(), data )){ throw( new CustomizationException( "Failed to save customization to " + target )); } } }catch( CustomizationException e ){ throw( e ); }catch( Throwable e ){ throw( new CustomizationException( "Failed to import customization", e )); } }