<commit_before><commit_msg>Steal some filename utility functions from aspirin<commit_after>//
// Flump - Copyright 2012 Three Rings Design

package flump.mold {

public class Files
{
    /**
     * Returns the substring composed of the characters after the last '.' in the supplied string.
     * The substring will be converted to lowercase.
     */
    public static function getDotSuffix (filename :String) :String
    {
        // is there a dot?
        var ix :int = filename.lastIndexOf(".");
        if (ix >= 0) {
            var ext :String = filename.substr(ix + 1);
            // is there a ?foo=bar component?
            ix = ext.indexOf('?');
            if (ix > 0) {
                ext = ext.substring(0, ix);
            }
            return ext.toLowerCase();
        }
        return "";
    }

    /**
     * Returns the substring composed of the characters before the last '.' in the supplied string.
     */
    public static function stripDotSuffix (filename :String) :String
    {
        var ix :int = filename.lastIndexOf(".");
        return (ix >= 0 ? filename.substr(0, ix) : filename);
    }

    /**
     * Returns the substring composed of the characters after the last path separator
     * in the supplied string.
     */
    public static function stripPath (filename :String, separator :String = "/") :String
    {
        var ix :int = filename.lastIndexOf(separator);
        return (ix >= 0 ? filename.substr(ix + 1) : filename);
    }

    /**
     * Strips the path and dot-suffix from the given filename.
     */
    public static function stripPathAndDotSuffix (filename :String, separator :String = "/") :String
    {
        return stripDotSuffix(stripPath(filename, separator));
    }
}

}
{'fraction_non_alphanumeric': 0.10874568469505179, 'fraction_numerical': 0.006904487917146145, 'mean_word_length': 2.167577413479053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2219952', 'n_tokens_mistral': 491, 'n_tokens_neox': 463, 'n_words': 165}