Пример #1
0
  /** Reads the suite settings from storage. */
  private void readSettings() {
    byte[] maximums = Permissions.getEmptySet();
    byte[] currentLevels = Permissions.getEmptySet();
    RandomAccessStream storage = new RandomAccessStream(classSecurityToken);
    DataInputStream storageStream;
    int version;
    int count;

    permissions = new byte[2][];
    permissions[Permissions.MAX_LEVELS] = maximums;
    permissions[Permissions.CUR_LEVELS] = currentLevels;

    try {
      storage.connect(getStorageRoot() + Installer.SETTINGS_FILENAME, Connector.READ);
      try {
        storageStream = storage.openDataInputStream();

        version = storageStream.readByte();
        /*
         * only version 1 are handled by the method
         * 0 means that this is a beta version that are not handled
         * by the method. Note that version number only has to
         * increase if data has been removed, not if new data has been
         * added to the end of the file.
         */
        if (version != 1) {
          System.out.println("Corrupt application settings file.");
          return;
        }

        trusted = storageStream.readBoolean();

        pushInterruptSetting = storageStream.readByte();

        count = storageStream.readByte();
        storageStream.readFully(currentLevels, 0, count);

        count = storageStream.readByte();
        storageStream.readFully(maximums, 0, count);
      } finally {
        storage.disconnect();
      }
    } catch (IOException e) {
      // ignore, old settings files are shorter
    }
  }