📄 totorrentfileimpl.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: TOTorrentFileImpl.java
package org.gudy.azureus2.core3.torrent.impl;
import java.io.*;
import java.util.Map;
import java.util.Vector;
import org.gudy.azureus2.core3.internat.*;
import org.gudy.azureus2.core3.torrent.*;
import org.gudy.azureus2.core3.util.*;
public class TOTorrentFileImpl
implements TOTorrentFile
{
private final TOTorrent torrent;
private final long file_length;
private final byte path_components[][];
private final int first_piece_number;
private final int last_piece_number;
private final Map additional_properties;
private final boolean is_utf8;
protected TOTorrentFileImpl(TOTorrent _torrent, long _torrent_offset, long _len, String _path)
throws TOTorrentException
{
additional_properties = new LightHashMap(1);
torrent = _torrent;
file_length = _len;
first_piece_number = (int)(_torrent_offset / torrent.getPieceLength());
last_piece_number = (int)(((_torrent_offset + file_length) - 1L) / torrent.getPieceLength());
is_utf8 = true;
try
{
Vector temp = new Vector();
int pos = 0;
do
{
int p1 = _path.indexOf(File.separator, pos);
if (p1 == -1)
{
temp.add(_path.substring(pos).getBytes("UTF8"));
break;
}
temp.add(_path.substring(pos, p1).getBytes("UTF8"));
pos = p1 + 1;
} while (true);
path_components = new byte[temp.size()][];
temp.copyInto(path_components);
checkComponents();
}
catch (UnsupportedEncodingException e)
{
throw new TOTorrentException((new StringBuilder()).append("Unsupported encoding for '").append(_path).append("'").toString(), 7);
}
}
protected TOTorrentFileImpl(TOTorrent _torrent, long _torrent_offset, long _len, byte _path_components[][])
throws TOTorrentException
{
additional_properties = new LightHashMap(1);
torrent = _torrent;
file_length = _len;
path_components = _path_components;
first_piece_number = (int)(_torrent_offset / torrent.getPieceLength());
last_piece_number = (int)(((_torrent_offset + file_length) - 1L) / torrent.getPieceLength());
is_utf8 = false;
checkComponents();
}
protected void checkComponents()
throws TOTorrentException
{
for (int i = 0; i < path_components.length; i++)
{
byte comp[] = path_components[i];
if (comp.length == 2 && comp[0] == 46 && comp[1] == 46)
throw new TOTorrentException("Torrent file contains illegal '..' component", 6);
if (i < path_components.length - 1)
path_components[i] = StringInterner.internBytes(path_components[i]);
}
}
public TOTorrent getTorrent()
{
return torrent;
}
public long getLength()
{
return file_length;
}
public byte[][] getPathComponents()
{
return path_components;
}
protected boolean isUTF8()
{
return is_utf8;
}
protected void setAdditionalProperty(String name, Object value)
{
additional_properties.put(name, value);
}
protected Map getAdditionalProperties()
{
return additional_properties;
}
public int getFirstPieceNumber()
{
return first_piece_number;
}
public int getLastPieceNumber()
{
return last_piece_number;
}
public int getNumberOfPieces()
{
return (getLastPieceNumber() - getFirstPieceNumber()) + 1;
}
public String getRelativePath()
{
if (torrent == null)
return "";
String sRelativePath = "";
LocaleUtilDecoder decoder = null;
try
{
decoder = LocaleTorrentUtil.getTorrentEncodingIfAvailable(torrent);
if (decoder == null)
{
LocaleUtil localeUtil = LocaleUtil.getSingleton();
decoder = localeUtil.getSystemDecoder();
}
}
catch (Exception e) { }
if (decoder != null)
{
for (int j = 0; j < path_components.length; j++)
try
{
String comp;
try
{
comp = decoder.decodeString(path_components[j]);
}
catch (UnsupportedEncodingException e)
{
System.out.println("file - unsupported encoding!!!!");
try
{
comp = new String(path_components[j]);
}
catch (Exception e2)
{
comp = "UnsupportedEncoding";
}
}
comp = FileUtil.convertOSSpecificChars(comp, j != path_components.length - 1);
sRelativePath = (new StringBuilder()).append(sRelativePath).append(j != 0 ? File.separator : "").append(comp).toString();
}
catch (Exception ex)
{
Debug.out(ex);
}
}
return sRelativePath;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -