public static String genSlaveFilename(String master_filename, String prefix_name, String ext_name)
            throws MyException {
        String true_ext_name;
        int dotIndex;

        if (master_filename.length() < 28 + FDFS_FILE_EXT_NAME_MAX_LEN) {
            throw new MyException("master filename \"" + master_filename + "\" is invalid");
        }

        dotIndex = master_filename.indexOf('.', master_filename.length() - (FDFS_FILE_EXT_NAME_MAX_LEN + 1));
        if (ext_name != null) {
            if (ext_name.length() == 0) {
                true_ext_name = "";
            } else if (ext_name.charAt(0) == '.') {
                true_ext_name = ext_name;
            } else {
                true_ext_name = "." + ext_name;
            }
        } else {
            if (dotIndex < 0) {
                true_ext_name = "";
            } else {
                true_ext_name = master_filename.substring(dotIndex);
            }
        }

        if (true_ext_name.length() == 0 && prefix_name.equals("-m")) {
            throw new MyException("prefix_name \"" + prefix_name + "\" is invalid");
        }

        if (dotIndex < 0) {
            return master_filename + prefix_name + true_ext_name;
        } else {
            return master_filename.substring(0, dotIndex) + prefix_name + true_ext_name;
        }
    }