home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / browser / net_linx / java40.jar / netscape / softupdate / FolderSpec.class (.txt) next >
Encoding:
Java Class File  |  1997-11-03  |  2.1 KB  |  83 lines

  1. package netscape.softupdate;
  2.  
  3. import netscape.security.Target;
  4.  
  5. final class FolderSpec {
  6.    private String urlPath = null;
  7.    private String folderID;
  8.    private String versionRegistryPath;
  9.    private String userPackageName;
  10.    static final int INVALID_PATH_ERR = -100;
  11.    static final int USER_CANCELLED_ERR = -101;
  12.  
  13.    FolderSpec(String var1, String var2, String var3) {
  14.       this.folderID = var1;
  15.       this.versionRegistryPath = var2;
  16.       this.userPackageName = var3;
  17.    }
  18.  
  19.    String GetDirectoryPath() throws SoftUpdateException {
  20.       Object var1 = null;
  21.       if (this.urlPath == null) {
  22.          if (this.folderID.compareTo("User Pick") == 0) {
  23.             this.urlPath = VersionRegistry.getDefaultDirectory(this.versionRegistryPath);
  24.             if (this.urlPath == null) {
  25.                this.PickDefaultDirectory();
  26.             }
  27.          } else if (this.folderID.compareTo("Installed") == 0) {
  28.             this.urlPath = this.versionRegistryPath;
  29.          } else {
  30.             int var2 = this.NativeGetDirectoryPath();
  31.             if (var2 != 0) {
  32.                throw new SoftUpdateException(this.folderID, var2);
  33.             }
  34.          }
  35.       }
  36.  
  37.       String var3 = this.urlPath;
  38.       return var3;
  39.    }
  40.  
  41.    String MakeFullPath(String var1) throws SoftUpdateException {
  42.       if (this.GetSecurityTargetID() == 0 && var1.regionMatches(0, "..", 0, 2)) {
  43.          throw new SoftUpdateException(Strings.error_IllegalPath(), -209);
  44.       } else {
  45.          String var2 = this.GetDirectoryPath() + this.GetNativePath(var1);
  46.          return var2;
  47.       }
  48.    }
  49.  
  50.    private native int NativeGetDirectoryPath();
  51.  
  52.    private native String GetNativePath(String var1);
  53.  
  54.    private void PickDefaultDirectory() throws SoftUpdateException {
  55.       this.urlPath = this.NativePickDefaultDirectory();
  56.       if (this.urlPath == null) {
  57.          throw new SoftUpdateException(this.folderID, -100);
  58.       } else {
  59.          VersionRegistry.setDefaultDirectory(this.versionRegistryPath, this.urlPath);
  60.       }
  61.    }
  62.  
  63.    private native String NativePickDefaultDirectory() throws SoftUpdateException;
  64.  
  65.    Target GetSecurityTarget() {
  66.       int var1 = this.GetSecurityTargetID();
  67.       return Target.findTarget(SoftwareUpdate.targetNames[var1]);
  68.    }
  69.  
  70.    private native int GetSecurityTargetID();
  71.  
  72.    public String toString() {
  73.       String var1;
  74.       try {
  75.          var1 = this.GetDirectoryPath();
  76.       } catch (Exception var2) {
  77.          var1 = null;
  78.       }
  79.  
  80.       return var1;
  81.    }
  82. }
  83.