コード例 #1
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilTranslateWinPath() Function : PclZipUtilTranslateWinPath() Description : Description
   * : Translate windows path by replacing '\' by '/' and optionally removing Translate windows path
   * by replacing '\' by '/' and optionally removing drive letter. drive letter. Parameters :
   * Parameters : $p_path : path to translate. $p_path : path to translate. $p_remove_disk_letter :
   * true | false $p_remove_disk_letter : true | false Return Values : Return Values : The path
   * translated. The path translated.
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public String PclZipUtilTranslateWinPath(String p_path, boolean p_remove_disk_letter) {
    int v_position = 0;

    if (booleanval(Strings.stristr(Options.php_uname(), "windows"))) /*
         * ----- Look for potential disk letter ----- Look for potential disk
         * letter
         *
         * ----- Change potential windows directory separator ----- Change
         * potential windows directory separator
         */ {
      if (p_remove_disk_letter && !equal(v_position = Strings.strpos(p_path, ":"), false)) {
        p_path = Strings.substr(p_path, v_position + 1);
      }

      if ((Strings.strpos(p_path, "\\") > 0) || equal(Strings.substr(p_path, 0, 1), "\\")) {
        p_path = Strings.strtr(p_path, "\\", "/");
      }
    }

    return p_path;
  }
コード例 #2
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilOptionText() Function : PclZipUtilOptionText() Description : Description : Translate
   * option value in text. Mainly for debug purpose. Translate option value in text. Mainly for
   * debug purpose. Parameters : Parameters : $p_option : the option value. $p_option : the option
   * value. Return Values : Return Values : The option text value. The option text value.
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public String PclZipUtilOptionText(Object p_option) {
    // Modified by Numiton
    Set<String> v_list = gConsts.constDefs;
    String v_prefix = null;
    String v_result = null;

    for (String v_key : v_list) {
      v_prefix = Strings.substr(v_key, 0, 10);

      if ((equal(v_prefix, "PCLZIP_OPT")
              || equal(v_prefix, "PCLZIP_CB_")
              || equal(v_prefix, "PCLZIP_ATT"))
          && equal(gConsts.getConstantValue(v_key), p_option)) /*
             * --(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
             * --(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
             */ {
        return v_key;
      }
    }

    v_result = "Unknown";

    return v_result;
  }
コード例 #3
0
  /**
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   * -------------------------------------------------------------------------------- Function :
   * PclZipUtilPathInclusion() Function : PclZipUtilPathInclusion() Description : Description : This
   * function indicates if the path $p_path is under the $p_dir tree. Or, This function indicates if
   * the path $p_path is under the $p_dir tree. Or, said in an other way, if the file or sub-dir
   * $p_path is inside the dir said in an other way, if the file or sub-dir $p_path is inside the
   * dir $p_dir. $p_dir. The function indicates also if the path is exactly the same as the dir. The
   * function indicates also if the path is exactly the same as the dir. This function supports path
   * with duplicated '/' like '//', but does not This function supports path with duplicated '/'
   * like '//', but does not support '.' or '..' statements. support '.' or '..' statements.
   * Parameters : Parameters : Return Values : Return Values : 0 if $p_path is not inside directory
   * $p_dir 0 if $p_path is not inside directory $p_dir 1 if $p_path is inside directory $p_dir 1 if
   * $p_path is inside directory $p_dir 2 if $p_path is exactly the same as $p_dir 2 if $p_path is
   * exactly the same as $p_dir
   * --------------------------------------------------------------------------------
   * --------------------------------------------------------------------------------
   */
  public int PclZipUtilPathInclusion(String p_dir, String p_path) {
    int v_result = 0;
    Array<String> v_list_dir = new Array<String>();
    int v_list_dir_size = 0;
    Array<String> v_list_path = new Array<String>();
    int v_list_path_size = 0;
    int i = 0;
    int j = 0;
    v_result = 1;

    if (equal(p_dir, ".")
        || ((Strings.strlen(p_dir) >= 2) && equal(Strings.substr(p_dir, 0, 2), "./"))) {
      p_dir =
          PclZipUtilTranslateWinPath(Directories.getcwd(gVars.webEnv), false)
              + "/"
              + Strings.substr(p_dir, 1);
    }

    if (equal(p_path, ".")
        || ((Strings.strlen(p_path) >= 2) && equal(Strings.substr(p_path, 0, 2), "./"))) {
      p_path =
          PclZipUtilTranslateWinPath(Directories.getcwd(gVars.webEnv), false)
              + "/"
              + Strings.substr(p_path, 1);
    }

    v_list_dir = Strings.explode("/", p_dir);
    v_list_dir_size = Array.sizeof(v_list_dir);
    v_list_path = Strings.explode("/", p_path);
    v_list_path_size = Array.sizeof(v_list_path);
    i = 0;
    j = 0;

    while ((i < v_list_dir_size) && (j < v_list_path_size) && booleanval(v_result)) /*
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
         * "Working on dir($i)='".$v_list_dir[$i]."' and
         * path($j)='".$v_list_path[$j]."'");
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
         * "Working on dir($i)='".$v_list_dir[$i]."' and
         * path($j)='".$v_list_path[$j]."'"); ----- Look for empty dir (path
         * reduction) ----- Look for empty dir (path reduction)
         */

    /*
     * ----- Compare the items ----- Compare the items
     */

    /*
     * ----- Next items ----- Next items
     */
    {
      if (equal(v_list_dir.getValue(i), "")) {
        i++;

        continue;
      }

      if (equal(v_list_path.getValue(j), "")) {
        j++;

        continue;
      }

      if (!equal(v_list_dir.getValue(i), v_list_path.getValue(j))
          && !equal(v_list_dir.getValue(i), "")
          && !equal(v_list_path.getValue(j), "")) /*
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
             * "Items ($i,$j) are different");
             * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5,
             * "Items ($i,$j) are different");
             */ {
        v_result = 0;
      }

      i++;
      j++;
    }

    if (booleanval(v_result)) /*
         * --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look
         * for tie break"); --(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__,
         * __LINE__, 5, "Look for tie break"); ----- Skip all the empty items
         * ----- Skip all the empty items
         */

    /*
     * ??$v_list_path[$j]:'')."'"); $v_list_path[$j]:'')."'");
     */
    {
      while ((j < v_list_path_size) && equal(v_list_path.getValue(j), "")) j++;

      while ((i < v_list_dir_size) && equal(v_list_dir.getValue(i), "")) i++;

      if ((i >= v_list_dir_size) && (j >= v_list_path_size)) /*
             * ----- There are exactly the same ----- There are exactly the same
             */ {
        v_result = 2;
      } else if (i < v_list_dir_size) /*
             * ----- The path is shorter than the dir ----- The path is
             * shorter than the dir
             */ {
        v_result = 0;
      }
    }

    return v_result;
  }