class FileUtils {

    public static String toPackageQualifiedName(String path) {
        path = removePrefix(path);
        path = path.replace('/', '.');
        if (path.contains(":\\")) { // to remove windows drive letter and colon
            path = removePrefix(path);
        }
        if (path.indexOf('\\') != -1) { // for windows paths
            path = path.replace('\\', '.');
        }
        String packagePath = path.replace("..", "");
        if (packagePath.startsWith(".")) {
            packagePath = packagePath.substring(1);
        }
        if (packagePath.endsWith(DOT_FEATURE)) {
            packagePath = packagePath.substring(0, packagePath.length() - 8);
        }
        return packagePath;
    }

}

class FileUtilsTest {

    private static final Logger logger;

    @Test
    public void testWindowsFileNames() {

        String path = "com/intuit/karate/cucumber/scenario.feature";
        String fixed = FileUtils.toPackageQualifiedName(path);
        assertEquals("com.intuit.karate.cucumber.scenario", fixed);
        path = "file:C:\\Users\\Karate\\scenario.feature";
        fixed = FileUtils.toPackageQualifiedName(path);
        assertEquals("Users.Karate.scenario", fixed);
        path = "file:../Karate/scenario.feature";
        fixed = FileUtils.toPackageQualifiedName(path);
        assertEquals("Karate.scenario", fixed);
    }

}