Jump to content
Sign in to follow this  
malimt

(PI) Changing Cache Path. (Works for MAC) (Upgraded Method)

Recommended Posts

Hello there,
I wanted to post a tutorial here today for the people who are suffering with their Cache'
It can be hard to understand it, it sure took me a while...
So, I want to teach you guys how to change your "Cache Path" There are multiple servers still as of today, that are using C:/ as their path and are having major problems with it.
This method here will make your client work with a MAC OS X as well, not to mention that, it will also locate the Cache if placed in your (C:/ Or Users.home)
I have a Macbook pro and sometimes I prefer to use that for coding via (Eclipse) So I have modified this to work with MAC.
Anyways, enough with the chit chat :p and back to work!

[Files we will be working on today:
[Signlink.java] [Client Sided] [Difficulty: 1.5/10]

First thing you want to do is:

1. Open Your Client Folder,

2. Locate (Signlink.java) In Your Client Files.

3. Open File (Signlink.java) With Notepad Or Notepad++ (Preferably Notepad++ ) (Mac users use: "Sublime Text 2 Or TextEdit")

4. Once Opened, Search For: " public static String findcachedir() "

5. Once Found, Keep In Mind That Your "Code" Will Most Likely Will Be Different, But usual PI's like: Lost Leg, InsidiaX, Hyperion, Deathly will have C:/ and some Users.home. Anyways, You're going to find 2 Codes on some 3. You Can Scroll Down Slowly From " public static String findcachedir() " And Eventually You Will Find: " public static String sencondDir() { " And On Some Servers You Might Have A Third One, If You Do It Should Be Right Under " public static String sencondDir() { " It's Called: " public static String findcachedirORIG() " And If You Don't Have That It's Fine, We Will Be Adding It Today...

6. Replace All 2, If You've Found 3, Then Change/Replace All 3 Codes With These Below:
(FYI) The 3 Codes Are:
[CODE]
1. public static String findcachedir()
2. public static String sencondDir() {
3. public static String findcachedirORIG()
[/CODE]

The New Codes You Will Be Replacing The Old Ones With:
[CODE]
public static String findcachedir()
{
boolean exists = (new File(System.getProperty("user.home") + "/YourCacheNameHere/")).exists();
if (exists) {
return System.getProperty("user.home") + "/YourCacheNameHere/";
} else {
File f = new File(System.getProperty("user.home") + "/YourCacheNameHere/");
f.mkdir();
return System.getProperty("user.home") + "/YourCacheNameHere/";
}
}
public static String sencondDir() {
File file = new File("c:/YourCacheNameHere/");
if (!file.exists())
file.mkdir();
return file.toString();
}

public static String findcachedirORIG()
{
String as[] = {
"c:/windows/", "c:/winnt/", "d:/windows/", "d:/winnt/", "e:/windows/", "e:/winnt/", "f:/windows/", "f:/winnt/", "c:/", "~/",
"/tmp/", "", "c:/rscache", "/rscache"
};
if(storeid < 32 || storeid > 34)
storeid = 32;
String s = ".file_store_" + storeid;
for(int i = 0; i < as.length; i++)
try
{
String s1 = as[i];
if(s1.length() > 0)
{
File file = new File(s1);
if(!file.exists())
continue;
}
File file1 = new File(s1 + s);
if(file1.exists() || file1.mkdir())
return s1 + s + "/";
}
catch(Exception _ex) { }

return null;

}
[/CODE]

Now this should work with most PI's ... Remember this only shows/teaches you how to change your "Cache Path, IN: SIGNLINK.JAVA" It has nothing to do with your (Cache Downloader) If you have any errors, please post below and I will try to help you out.
I hope this helps you guys! Good luck!

Share this post


Link to post
Share on other sites
Maybe a more simple method?

[CODE]

private static final String cacheName = "YOUR_CACHE_NAME";// Declare This Somewhere.

/*
* Replace your findcachedir with this one:

*/
public static String findcachedir() {
File cacheFile = new File(System.getProperty("user.home") + "/" + cacheName + "/");
if (!cacheFile.exists())
cacheFile.mkdir();
return System.getProperty("user.home") + "/" + cacheName + "/";
}
[/CODE]
The return could be changed to "return cacheFile.getCanonicalPath();" but that throws an IOException. You'd have to add a try/catch or add a throws IOException (Then you'd have to add lots more try/catches).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×