public String getDirectoryParameter(String parameter) throws IOException { String dir = getStringParameter(parameter); if( dir.length() > 0 ) { File temp = new File(dir); if (!temp.exists()) { FileUtil.mkdirs(temp); } if (!temp.isDirectory()) { throw new IOException("Configuration error. This is not a directory: " + dir); } } return dir; }
protected File getDataDir( int network ) { File dir = new File( plugin_interface.getUtilities().getUserDir(), "dht" ); if ( network != 0 ){ dir = new File( dir, "net" + network ); } FileUtil.mkdirs(dir); return( dir ); }
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 ); } }
protected String getNewTorrentLocation() throws ShareException { for (int i=1;i<=MAX_DIRS;i++){ String cache_dir_str = share_dir + File.separator + TORRENT_SUBSTORE + i; File cache_dir = new File(cache_dir_str); if ( !cache_dir.exists()){ FileUtil.mkdirs(cache_dir); } if ( cache_dir.listFiles().length < MAX_FILES_PER_DIR ){ for (int j=0;j<MAX_FILES_PER_DIR;j++){ long file = RandomUtils.nextAbsoluteLong(); File file_name = new File(cache_dir_str + File.separator + file + ".torrent"); if ( !file_name.exists()){ // return path relative to cache_dir to save space return( TORRENT_SUBSTORE + i + File.separator + file + ".torrent" ); } } } } throw( new ShareException( "ShareManager: Failed to allocate cache file")); }
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" )); } } }
@Override public File getPluginUserFile( String name ) { String dir = plugin_interface.getUtilities().getUserDir(); File file = new File( dir, "plugins" ); String p_dir = plugin_interface.getPluginDirectoryName(); if ( p_dir.length() != 0 ){ int lp = p_dir.lastIndexOf(File.separatorChar); if ( lp != -1 ){ p_dir = p_dir.substring(lp+1); } file = new File( file, p_dir ); }else{ String id = plugin_interface.getPluginID(); if ( id.length() > 0 && !id.equals( PluginInitializer.INTERNAL_PLUGIN_ID )){ file = new File( file, id ); }else{ throw( new RuntimeException( "Plugin was not loaded from a directory" )); } } FileUtil.mkdirs(file); return( new File( file, name )); }
FileUtil.mkdirs(torrentDir);
FileUtil.mkdirs(pluginDirectory);
protected UpdateInstallerImpl( UpdateManagerImpl _manager ) throws UpdateException { manager = _manager; try{ class_mon.enter(); // updates are in general user-specific (e.g. plugin updates) so store here // obviously core ones will affect all users String update_dir = getUserDir() + File.separator + UPDATE_DIR; for (int i=1;i<1024;i++){ File try_dir = new File( update_dir + File.separator + "inst_" + i ); if ( !try_dir.exists()){ if ( !FileUtil.mkdirs(try_dir)){ throw( new UpdateException( "Failed to create a temporary installation dir")); } install_dir = try_dir; break; } } if ( install_dir == null ){ throw( new UpdateException( "Failed to find a temporary installation dir")); } }finally{ class_mon.exit(); } }
boolean dir_created = FileUtil.mkdirs(parent);
FileUtil.mkdirs(to_file_parent);
FileUtil.mkdirs(data_location);
FileUtil.mkdirs(new_save_location.getParentFile());
FileUtil.mkdirs(share_dir);
if (!controlFileDir.isDirectory() && !FileUtil.mkdirs(controlFileDir)) { throw new FMFileManagerException("Directory creation failed: " + controlFileDir);
FileUtil.mkdirs(data_dir);
FileUtil.mkdirs(f);
FileUtil.mkdirs(download_dir);