Skip to content

Commit

Permalink
fix output filename generation on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo committed Apr 22, 2024
1 parent 79b9de0 commit e51bfc9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/crml/compiler/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ public class Utilities {

/**
* Remove the last .* of a name and the directory path
* /path/to/some/FILE.ext -> FILE
* @return
*/
public static String stripNameEndingAndPath(String name) {
int firstIndex = name.lastIndexOf("/");
if (firstIndex==-1)
firstIndex=0;

File f = new File(name);
String fileName = f.getName();
// check if it even has an extension and return the name if not!
if (name.lastIndexOf('.') == -1) {
return name.substring(firstIndex);
int dotPos = fileName.lastIndexOf('.');
if (dotPos == -1) {
return fileName;
}
return name.substring(firstIndex, name.lastIndexOf('.'));
return fileName.substring(0, dotPos);
}

public static String addDirToPath (String path, String dir){
Expand Down

0 comments on commit e51bfc9

Please sign in to comment.