⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updateinstallerimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   UpdateInstallerImpl.java

package org.gudy.azureus2.pluginsimpl.local.update;

import java.io.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.LogAlert;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.platform.*;
import org.gudy.azureus2.plugins.update.*;

public class UpdateInstallerImpl
	implements UpdateInstaller
{

	protected static final String UPDATE_DIR = "updates";
	protected static final String ACTIONS = "install.act";
	protected static AEMonitor class_mon = new AEMonitor("UpdateInstaller:class");
	private UpdateManager manager;
	private File install_dir;

	protected static void checkForFailedInstalls(UpdateManager manager)
	{
		try
		{
			File update_dir = new File((new StringBuilder()).append(manager.getUserDir()).append(File.separator).append("updates").toString());
			File dirs[] = update_dir.listFiles();
			if (dirs != null)
			{
				boolean found_failure = false;
				String files = "";
				for (int i = 0; i < dirs.length; i++)
				{
					File dir = dirs[i];
					if (!dir.isDirectory())
						continue;
					found_failure = true;
					File x[] = dir.listFiles();
					if (x != null)
					{
						for (int j = 0; j < x.length; j++)
							files = (new StringBuilder()).append(files).append(files.length() != 0 ? "," : "").append(x[j].getName()).toString();

					}
					FileUtil.recursiveDelete(dir);
				}

				if (found_failure)
					Logger.log(new LogAlert(false, 3, MessageText.getString("Alert.failed.update", new String[] {
						files
					})));
			}
		}
		catch (Throwable e)
		{
			Debug.printStackTrace(e);
		}
	}

	protected UpdateInstallerImpl(UpdateManager _manager)
		throws UpdateException
	{
		manager = _manager;
		class_mon.enter();
		String update_dir = (new StringBuilder()).append(getUserDir()).append(File.separator).append("updates").toString();
		int i = 1;
		do
		{
			if (i >= 1024)
				break;
			File try_dir = new File((new StringBuilder()).append(update_dir).append(File.separator).append("inst_").append(i).toString());
			if (!try_dir.exists())
			{
				if (!FileUtil.mkdirs(try_dir))
					throw new UpdateException("Failed to create a temporary installation dir");
				install_dir = try_dir;
				break;
			}
			i++;
		} while (true);
		if (install_dir == null)
			throw new UpdateException("Failed to find a temporary installation dir");
		class_mon.exit();
		break MISSING_BLOCK_LABEL_169;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void addResource(String resource_name, InputStream is)
		throws UpdateException
	{
		addResource(resource_name, is, true);
	}

	public void addResource(String resource_name, InputStream is, boolean closeInputStream)
		throws UpdateException
	{
		try
		{
			File target_file = new File(install_dir, resource_name);
			FileUtil.copyFile(is, new FileOutputStream(target_file), closeInputStream);
		}
		catch (Throwable e)
		{
			throw new UpdateException("UpdateInstaller: resource addition fails", e);
		}
	}

	public String getInstallDir()
	{
		return manager.getInstallDir();
	}

	public String getUserDir()
	{
		return manager.getUserDir();
	}

	public void addMoveAction(String from_file_or_resource, String to_file)
		throws UpdateException
	{
		if (from_file_or_resource.indexOf(File.separator) == -1)
			from_file_or_resource = (new StringBuilder()).append(install_dir.toString()).append(File.separator).append(from_file_or_resource).toString();
		try
		{
			File to_f = new File(to_file);
			File parent = to_f.getParentFile();
			if (parent != null && !parent.exists())
				parent.mkdirs();
			if (parent != null && !parent.canWrite() && !Constants.isWindowsVista)
				Logger.log(new LogAlert(false, 1, (new StringBuilder()).append("The location '").append(parent.toString()).append("' isn't writable, this update will probably fail.").append(" Check permissions and retry the update").toString()));
			try
			{
				PlatformManager pm = PlatformManagerFactory.getPlatformManager();
				if (pm.hasCapability(PlatformManagerCapabilities.CopyFilePermissions))
				{
					String parent_str = parent.getAbsolutePath();
					PlatformManagerFactory.getPlatformManager().copyFilePermissions(parent_str, from_file_or_resource);
				}
			}
			catch (Throwable e)
			{
				Debug.out(e);
			}
		}
		catch (Throwable e) { }
		appendAction((new StringBuilder()).append("move,").append(from_file_or_resource).append(",").append(to_file).toString());
	}

	public void addChangeRightsAction(String rights, String to_file)
		throws UpdateException
	{
		appendAction((new StringBuilder()).append("chmod,").append(rights).append(",").append(to_file).toString());
	}

	public void addRemoveAction(String file)
		throws UpdateException
	{
		appendAction((new StringBuilder()).append("remove,").append(file).toString());
	}

	protected void appendAction(String data)
		throws UpdateException
	{
		PrintWriter pw;
		Exception exception;
		pw = null;
		try
		{
			pw = new PrintWriter(new FileWriter((new StringBuilder()).append(install_dir.toString()).append(File.separator).append("install.act").toString(), true));
			pw.println(data);
		}
		catch (Throwable e)
		{
			throw new UpdateException("Failed to write actions file", e);
		}
		finally
		{
			if (pw == null) goto _L0; else goto _L0
		}
		if (pw != null)
			try
			{
				pw.close();
			}
			catch (Throwable e)
			{
				throw new UpdateException("Failed to write actions file", e);
			}
		break MISSING_BLOCK_LABEL_119;
		try
		{
			pw.close();
		}
		catch (Throwable e)
		{
			throw new UpdateException("Failed to write actions file", e);
		}
		throw exception;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -