Esempio n. 1
0
  public static List<Library> list(File folder) {
    List<Library> libraries = new ArrayList<Library>();
    List<File> librariesFolders = new ArrayList<File>();
    librariesFolders.addAll(discover(folder));

    for (File baseFolder : librariesFolders) {
      libraries.add(new Library(baseFolder));
    }

    // Support libraries inside of one level of subfolders? I believe this was
    // the compromise for supporting library groups, but probably a bad idea
    // because it's not compatible with the Manager.
    String[] folderNames = folder.list(junkFolderFilter);
    if (folderNames != null) {
      for (String subfolderName : folderNames) {
        File subfolder = new File(folder, subfolderName);

        if (!librariesFolders.contains(subfolder)) {
          List<File> discoveredLibFolders = discover(subfolder);
          for (File discoveredFolder : discoveredLibFolders) {
            libraries.add(new Library(discoveredFolder, subfolderName));
          }
        }
      }
    }
    return libraries;
  }
  public void setup() {
    size(1000, 700);

    File dir = new File("/Users/quoctrungbui/Desktop/work/img/crop/"); // load path and count files
    images = dir.list();
    filecount = images.length;

    for (int i = 1; i < filecount; i++) {
      img[i] = loadImage("/Users/quoctrungbui/Desktop/work/img/crop/" + images[i]); // load files
    }
    frameRate(2);
  }
Esempio n. 3
0
 /** List who's inside a windows64, macosx, linux32, etc folder. */
 static String[] listPlatformEntries(File libraryFolder, String folderName, String[] baseList) {
   File folder = new File(libraryFolder, folderName);
   if (folder.exists()) {
     String[] entries = folder.list(standardFilter);
     if (entries != null) {
       String[] outgoing = new String[entries.length + baseList.length];
       for (int i = 0; i < entries.length; i++) {
         outgoing[i] = folderName + "/" + entries[i];
       }
       // Copy the base libraries in there as well
       System.arraycopy(baseList, 0, outgoing, entries.length, baseList.length);
       return outgoing;
     }
   }
   return null;
 }
Esempio n. 4
0
  // this prepends a colon so that it can be appended to other paths safely
  public String getClassPath() {
    StringBuilder cp = new StringBuilder();

    //    PApplet.println(libraryFolder.getAbsolutePath());
    //    PApplet.println(libraryFolder.list());
    String[] jarHeads = libraryFolder.list(jarFilter);
    for (String jar : jarHeads) {
      cp.append(File.pathSeparatorChar);
      cp.append(new File(libraryFolder, jar).getAbsolutePath());
    }
    jarHeads = new File(nativeLibraryPath).list(jarFilter);
    for (String jar : jarHeads) {
      cp.append(File.pathSeparatorChar);
      cp.append(new File(nativeLibraryPath, jar).getAbsolutePath());
    }
    // cp.setLength(cp.length() - 1);  // remove the last separator
    return cp.toString();
  }
Esempio n. 5
0
  public static List<File> discover(File folder) {
    List<File> libraries = new ArrayList<File>();
    String[] folderNames = folder.list(junkFolderFilter);

    // if a bad folder or something like that, this might come back null
    if (folderNames != null) {
      // alphabetize list, since it's not always alpha order
      // replaced hella slow bubble sort with this feller for 0093
      Arrays.sort(folderNames, String.CASE_INSENSITIVE_ORDER);

      for (String potentialName : folderNames) {
        File baseFolder = new File(folder, potentialName);
        File libraryFolder = new File(baseFolder, "library");
        File libraryJar = new File(libraryFolder, potentialName + ".jar");
        // If a .jar file of the same prefix as the folder exists
        // inside the 'library' subfolder of the sketch
        if (libraryJar.exists()) {
          String sanityCheck = Sketch.sanitizeName(potentialName);
          if (sanityCheck.equals(potentialName)) {
            libraries.add(baseFolder);

          } else {
            String mess =
                "The library \""
                    + potentialName
                    + "\" cannot be used.\n"
                    + "Library names must contain only basic letters and numbers.\n"
                    + "(ASCII only and no spaces, and it cannot start with a number)";
            Messages.showMessage("Ignoring bad library name", mess);
            continue;
          }
        }
      }
    }
    return libraries;
  }
Esempio n. 6
0
  private Library(File folder, String groupName) {
    super(folder);
    this.group = groupName;

    libraryFolder = new File(folder, "library");
    examplesFolder = new File(folder, "examples");
    referenceFile = new File(folder, "reference/index.html");

    File exportSettings = new File(libraryFolder, "export.txt");
    StringDict exportTable =
        exportSettings.exists() ? Util.readSettings(exportSettings) : new StringDict();

    exportList = new HashMap<String, String[]>();

    // get the list of files just in the library root
    String[] baseList = libraryFolder.list(standardFilter);
    //    System.out.println("Loading " + name + "...");
    //    PApplet.println(baseList);

    String appletExportStr = exportTable.get("applet");
    if (appletExportStr != null) {
      appletExportList = PApplet.splitTokens(appletExportStr, ", ");
    } else {
      appletExportList = baseList;
    }

    String androidExportStr = exportTable.get("android");
    if (androidExportStr != null) {
      androidExportList = PApplet.splitTokens(androidExportStr, ", ");
    } else {
      androidExportList = baseList;
    }

    // for the host platform, need to figure out what's available
    File nativeLibraryFolder = libraryFolder;
    String hostPlatform = Platform.getName();
    //    System.out.println("1 native lib folder now " + nativeLibraryFolder);
    // see if there's a 'windows', 'macosx', or 'linux' folder
    File hostLibrary = new File(libraryFolder, hostPlatform);
    if (hostLibrary.exists()) {
      nativeLibraryFolder = hostLibrary;
    }
    //    System.out.println("2 native lib folder now " + nativeLibraryFolder);
    // check for bit-specific version, e.g. on windows, check if there
    // is a window32 or windows64 folder (on windows)
    hostLibrary = new File(libraryFolder, hostPlatform + Platform.getNativeBits());
    if (hostLibrary.exists()) {
      nativeLibraryFolder = hostLibrary;
    }
    //    System.out.println("3 native lib folder now " + nativeLibraryFolder);

    if (hostPlatform.equals("linux") && System.getProperty("os.arch").equals("arm")) {
      hostLibrary = new File(libraryFolder, "linux-armv6hf");
      if (hostLibrary.exists()) {
        nativeLibraryFolder = hostLibrary;
      }
    }

    // save that folder for later use
    nativeLibraryPath = nativeLibraryFolder.getAbsolutePath();

    // for each individual platform that this library supports, figure out what's around
    for (int i = 1; i < platformNames.length; i++) {
      String platformName = platformNames[i];
      String platformName32 = platformName + "32";
      String platformName64 = platformName + "64";
      String platformNameArmv6hh = platformName + "-armv6hf";

      // First check for things like 'application.macosx=' or 'application.windows32' in the
      // export.txt file.
      // These will override anything in the platform-specific subfolders.
      String platformAll = exportTable.get("application." + platformName);
      String[] platformList = platformAll == null ? null : PApplet.splitTokens(platformAll, ", ");
      String platform32 = exportTable.get("application." + platformName + "32");
      String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", ");
      String platform64 = exportTable.get("application." + platformName + "64");
      String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", ");
      String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf");
      String[] platformListArmv6hf =
          platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", ");

      // If nothing specified in the export.txt entries, look for the platform-specific folders.
      if (platformAll == null) {
        platformList = listPlatformEntries(libraryFolder, platformName, baseList);
      }
      if (platform32 == null) {
        platformList32 = listPlatformEntries(libraryFolder, platformName32, baseList);
      }
      if (platform64 == null) {
        platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList);
      }
      if (platformListArmv6hf == null) {
        platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList);
      }

      if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) {
        multipleArch[i] = true;
      }

      // if there aren't any relevant imports specified or in their own folders,
      // then use the baseList (root of the library folder) as the default.
      if (platformList == null
          && platformList32 == null
          && platformList64 == null
          && platformListArmv6hf == null) {
        exportList.put(platformName, baseList);

      } else {
        // once we've figured out which side our bread is buttered on, save it.
        // (also concatenate the list of files in the root folder as well
        if (platformList != null) {
          exportList.put(platformName, platformList);
        }
        if (platformList32 != null) {
          exportList.put(platformName32, platformList32);
        }
        if (platformList64 != null) {
          exportList.put(platformName64, platformList64);
        }
        if (platformListArmv6hf != null) {
          exportList.put(platformNameArmv6hh, platformListArmv6hf);
        }
      }
    }
    //    for (String p : exportList.keySet()) {
    //      System.out.println(p + " -> ");
    //      PApplet.println(exportList.get(p));
    //    }

    // get the path for all .jar files in this code folder
    packageList = Util.packageListFromClassPath(getClassPath());
  }