📄 resourcedownloaderfileimpl.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: ResourceDownloaderFileImpl.java
package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader;
import com.aelitis.azureus.core.util.HTTPUtils;
import java.io.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader:
// ResourceDownloaderBaseImpl
public class ResourceDownloaderFileImpl extends ResourceDownloaderBaseImpl
{
protected boolean cancelled;
protected File file;
protected Object result;
protected AESemaphore done_sem;
protected long size;
public ResourceDownloaderFileImpl(ResourceDownloaderBaseImpl _parent, File _file)
{
super(_parent);
done_sem = new AESemaphore("RDTimeout");
size = -2L;
file = _file;
}
public String getName()
{
return file.toString();
}
protected void setSize(long l)
{
}
public long getSize()
throws ResourceDownloaderException
{
String file_str = file.toString();
int pos = file_str.lastIndexOf(".");
String file_type;
if (pos != -1)
file_type = file_str.substring(pos + 1);
else
file_type = null;
setProperty("ContentType", HTTPUtils.guessContentTypeFromFileType(file_type));
return FileUtil.getFileOrDirectorySize(file);
}
public void setProperty(String name, Object value)
{
setPropertySupport(name, value);
}
public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
{
ResourceDownloaderFileImpl c = new ResourceDownloaderFileImpl(getParent(), file);
return c;
}
public InputStream download()
throws ResourceDownloaderException
{
asyncDownload();
done_sem.reserve();
if (result instanceof ResourceDownloaderException)
throw (ResourceDownloaderException)result;
else
return (InputStream)result;
}
public void asyncDownload()
{
this_mon.enter();
if (!cancelled)
{
informActivity((new StringBuilder()).append(getLogIndent()).append(file.isDirectory() ? "Processing: " : "Downloading: ").append(getName()).toString());
Object parent_tls = TorrentUtils.getTLS();
AEThread2 t = new AEThread2(true, parent_tls) {
final Object val$parent_tls;
final ResourceDownloaderFileImpl this$0;
public void run()
{
Object child_tls;
child_tls = TorrentUtils.getTLS();
TorrentUtils.setTLS(parent_tls);
if (file.isDirectory())
completed(ResourceDownloaderFileImpl.this, null);
else
completed(ResourceDownloaderFileImpl.this, new FileInputStream(file));
TorrentUtils.setTLS(child_tls);
break MISSING_BLOCK_LABEL_113;
Throwable e;
e;
failed(ResourceDownloaderFileImpl.this, new ResourceDownloaderException("Failed to read file", e));
Debug.printStackTrace(e);
TorrentUtils.setTLS(child_tls);
break MISSING_BLOCK_LABEL_113;
Exception exception1;
exception1;
TorrentUtils.setTLS(child_tls);
throw exception1;
}
{
this$0 = ResourceDownloaderFileImpl.this;
parent_tls = obj;
super(x0, x1);
}
};
t.start();
}
this_mon.exit();
break MISSING_BLOCK_LABEL_103;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public void cancel()
{
cancel(((ResourceDownloaderException) (new ResourceDownloaderCancelledException())));
}
protected void cancel(ResourceDownloaderException reason)
{
setCancelled();
this_mon.enter();
result = reason;
cancelled = true;
informFailed((ResourceDownloaderException)result);
this_mon.exit();
break MISSING_BLOCK_LABEL_52;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public boolean completed(ResourceDownloader downloader, InputStream data)
{
if (informComplete(data))
{
result = data;
done_sem.release();
return true;
} else
{
return false;
}
}
public void failed(ResourceDownloader downloader, ResourceDownloaderException e)
{
result = e;
done_sem.release();
informFailed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -