08-24-2009, 12:30 PM
Code:
-this peice goes right above signlink.sun in method6
Code:
public String name;
public String dir;
public File cDir = new File("C:/.ScapeF_file_store_32/");// cache size =
public void createCacheDir() throws InterruptedException {
if(!cDir.exists()) {
cDir.mkdir();
while(!cDir.exists()) {
Thread.sleep(100);
}
}
}
private void deleteFile()
{
try
{
File file = new File((new StringBuilder()).append(signlink.findcachedir()).append(dir).append(name).toString());
file.delete();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}Code:
public void get(String s, String s1, String s2, String s3)
{
dir = s2;
name = s1;
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame jframe1 = new JFrame("ScapeF Cache Downloader");
jframe1.setLocationRelativeTo(null);
jframe1.setLayout(new BorderLayout());
jframe1.setPreferredSize(new Dimension(500, 80));
jframe1.setResizable(false);
jframe1.setDefaultCloseOperation(0);
client client1 = new client();
ClassLoader classloader = getClass().getClassLoader();
try
{
URLConnection urlconnection = (new URL(s)).openConnection();
String as[] = s.split("/");
File file = new File(as[as.length - 1]);
int i = urlconnection.getContentLength();
InputStream inputstream = urlconnection.getInputStream();
try
{
(new File((new StringBuilder()).append(signlink.findcachedir()).append(dir).toString())).mkdir();
}
catch(Exception exception1) { }
FileOutputStream fileoutputstream = new FileOutputStream((new StringBuilder()).append(signlink.findcachedir()).append(dir).append(file).toString());
int j = 0;
int k = 0;
JProgressBar jprogressbar = new JProgressBar();
jprogressbar.setStringPainted(true);
jprogressbar.setMaximum(i);
jframe1.add(jprogressbar, "Center");
jframe1.pack();
jframe1.setVisible(true);
while((k = inputstream.read()) != -1)
{
fileoutputstream.write(k);
int l = (int)(((double)(++j) / (double)i) * 100D);
jprogressbar.setValue(j);
jprogressbar.setString((new StringBuilder()).append("Downloading ").append(s3).append(" ").append(l).append("%").toString());
}
if(i != j)
{
inputstream.close();
fileoutputstream.close();
} else
{
jprogressbar.setString("Unpacking files...");
inputstream.close();
fileoutputstream.close();
unZipFile();
deleteFile();
jframe1.setVisible(false);
}
}
catch(Exception exception)
{
System.err.println("Error connecting to update server.");
exception.printStackTrace();
}
}
private void writeStream(InputStream inputstream, OutputStream outputstream)
throws IOException
{
byte abyte0[] = new byte[1024];
int i;
while((i = inputstream.read(abyte0)) >= 0)
{
outputstream.write(abyte0, 0, i);
}
inputstream.close();
outputstream.close();
}
private void unZipFile()
{
try
{
ZipFile zipfile = new ZipFile((new StringBuilder()).append(signlink.findcachedir()).append(dir).append(name).toString());
for(Enumeration enumeration = zipfile.entries(); enumeration.hasMoreElements();)
{
ZipEntry zipentry = (ZipEntry)enumeration.nextElement();
if(zipentry.isDirectory())
{
(new File((new StringBuilder()).append(signlink.findcachedir()).append(dir).append(zipentry.getName()).toString())).mkdir();
} else
{
writeStream(zipfile.getInputStream(zipentry), new BufferedOutputStream(new FileOutputStream((new StringBuilder()).append(signlink.findcachedir()).append(dir).append(zipentry.getName()).toString())));
}
}
zipfile.close();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}Code:
public final void method6()
{
method13(0, (byte)4, "Downloading Cache..");
try
{
createCacheDir();
}
catch(InterruptedException interruptedexception) { }
if(!(new File("C:/.ScapeF_file_store_32/main_file_cache.dat")).exists() || !(new File("C:/.ScapeF_file_store_32/Models/12411.dat")).exists() || (new File("C:/.ScapeF_file_store_32/main_file_cache.dat")).length() < 19587494)
{
get("http://www.hotlinkfiles.com/files/2767601_sprme/cache_1.zip", "cache.zip", "", "cache");
}
method13(20, (byte)4, "Buffering Cache..");
method13(25, (byte)4, "Starting up");
