public static String getRelativePath()

in src/main/java/org/apache/maven/shared/utils/PathTool.java [76:109]


    public static String getRelativePath(@Nullable String basedir, @Nullable String filename) {
        basedir = uppercaseDrive(basedir);
        filename = uppercaseDrive(filename);

        /*
         * Verify the arguments and make sure the filename is relative
         * to the base directory.
         */
        if (basedir == null
                || basedir.length() == 0
                || filename == null
                || filename.length() == 0
                || !filename.startsWith(basedir)) {
            return "";
        }

        /*
         * Normalize the arguments.  First, determine the file separator
         * that is being used, then strip that off the end of both the
         * base directory and filename.
         */
        String separator = determineSeparator(filename);
        basedir = StringUtils.chompLast(basedir, separator);
        filename = StringUtils.chompLast(filename, separator);

        /*
         * Remove the base directory from the filename to end up with a
         * relative filename (relative to the base directory).  This
         * filename is then used to determine the relative path.
         */
        String relativeFilename = filename.substring(basedir.length());

        return determineRelativePath(relativeFilename, separator);
    }