dir = new File(home, "/irate"); if (isMac()) {   if (!dir.exists() && new File(home, "/Music").exists()) { dir = new File(home, "/Music/iRATE"); } }
dir = Preferences.getPrefsDirectory();
  public AbstractClient() {		init();    userPreferences = new Preferences();    lastRatedTrack = null;    lastTrackPreviousRank = -1;    File home = new File(System.getProperties().getProperty("user.home"));    File dir = null;    File file = null;    File downloadDir = null;    // Check to see if the iRATE directory exists in the user's home.    // This needs to be there.    dir = new File(home, "/irate");    if (isMac()) {      // If the user doesn't already have an irate dir and hasn't removed ~/Music,      // let's put our stuff there alongside iTunes etc.      if (!dir.exists() && new File(home, "/Music").exists()) {        dir = new File(home, "/Music/iRATE");      }    }    if (!dir.exists()) {      dir.mkdir();    }    // Check to see if the user has a track database directory set in the    // irate.xml file.  If so, this directory should point to the trackdatabase.xml    // file.    String preference = Preferences.getUserDownloadDirectoryPreference();    if (preference != null) {      file = new File(preference);      downloadDir = new File(file.getParentFile(), "download/");          }    else {      // If they don't have one set, fall back on the home directory.      // If it doesn't exist in either location, then the user will need to fill in the      // registration information.      downloadDir = new File(dir, "download/");      file = new File(dir, "trackdatabase.xml");    }    try {      trackDatabase = new TrackDatabase(file);    }    catch (IOException e) {      e.printStackTrace();    }    playerList = new PlayerList();    // Add the client as a player listener on each player.    // If this doesn't make sense in the future, we'll have to look    // at doing this another way.    for (int i = 0; i < playerList.getPlayers().length; ++i) {      playerList.getPlayers()[i].addPlayerListener(this);    }    playListManager = new PlayListManager(trackDatabase);    playThread = new PlayThread(playListManager, playerList);    soundEventPlayer  = new SoundEventPlayer(playListManager);    if (playerList.getPlayers().length == 0)      handleError(null, "missingplayer.html");    playThread.addUpdateListener(this);    downloadThread = new DownloadThread(trackDatabase) {      public void process() throws IOException {        super.process();        // perhapsDisableAccount();      }      public void handleError(String code, String urlString) {        AbstractClient.this.handleError(code, urlString);      }    };    downloadThread.addDownloadListener(new DownloadListener() {      public void downloadStarted(Track track) {}      public void downloadProgressed(Track track, int percentComplete, String state) {        updateDownloadInfo(track, state, percentComplete);      }      public void downloadData(Track track, byte[] buffer, int offset, int length) {}      public void downloadFinished(Track track, boolean succeeded) {}    });    pluginManager = new PluginManager(this, dir);    System.out.println("Number of tracks "+trackDatabase.getNoOfTracks() );		// If a track database couldn't be loaded from the file system, then we    // need to create a new account.    if (trackDatabase.getNoOfTracks() == 0) {      createNewAccount();    }            // Deal with some file cleanup here -- if the user has the maximum disk amount    // set then we need to mark some files to be deleted.    String downloadLimit = Preferences.getUserPreference("downloadLimit");    if (downloadLimit != null) {        DiskControl dc = new DiskControl(downloadDir, trackDatabase);        dc.clearDiskSpace(new Integer(downloadLimit).intValue());     }          }