コード例 #1
0
  /**
   * Crawls the given directory for the toast_autorun.conf file. If the file is found, the USB
   * storage device is configured using it. If it is not found, the user is warned and the device
   * marked as 'Invalid'. Running 'usb generate' will validate any invalid drives by generating this
   * file. A restart will be required after runnning the generate command.
   */
  public static void crawlSym(File file) {
    if (!file.exists()) return;
    try {
      File canon = file.getCanonicalFile();
      if (!canon.exists()) return;

      File configuration = new File(canon, "toast_autorun.conf");
      if (!configuration.exists()) {
        invalidDrives.add(canon);
        logger.warn(
            "Invalid USB Mass Storage Device Detected -- No toast_autorun.conf file: " + canon);
        logger.warn(
            "Run 'usb generate' to create a new toast_autorun.conf file on any invalid drives");
        return;
      }

      ProfilerEntity profilerEntity = new ProfilerEntity().start();
      ModuleConfig pref = new ModuleConfig(configuration);
      String drive_name =
          pref.getString("toast.device_name", "Team_####_USB_Device").replace(" ", "_");
      MassStorageDevice device = new MassStorageDevice(canon, pref, drive_name);
      connectedDevices.add(device);
      if (device.override_modules && !device.concurrent_modules) override = true;

      logger.info(
          "USB Mass Storage Device Detected -- Valid! " + canon + " (" + device.drive_name + ")");

      if (device.config_priority >= config_last) {
        config_highest = device;
        config_last = device.config_priority;
      }
      if (device.filesystem_priority >= filesystem_last) {
        filesystem_highest = device;
        filesystem_last = device.filesystem_priority;
      }
      profilerEntity.stop();
      profilerEntity.setName(drive_name);
      Profiler.INSTANCE.section("USB").pushEntity(profilerEntity);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }