[ClavaWeaver] Fixes methods in CxxFile related with paths, when the path
of the file does not exist yet
@@ -250,19 +250,20 @@ public class CxxFile extends AFile {
@Override
public String getFilepathImpl() {
- return new File(getPathImpl(), getNameImpl()).getPath();
+ return tunit.getFile().getPath();
}
@Override
public String getRelativeFolderpathImpl() {
CxxWeaver weaver = getWeaverEngine();
- String path = weaver.getApp().getRelativeFolderPath(weaver.getBaseSourceFolder(), tunit);
-
- if (path.isEmpty()) {
- return "./";
+ // If file does not exist yet, return its path
+ if (!tunit.getFile().isFile()) {
+ return tunit.getFolderpath();
}
+ String path = weaver.getApp().getRelativeFolderPath(weaver.getBaseSourceFolder(), tunit);
+
return path;
}
@@ -271,6 +272,11 @@ public class CxxFile extends AFile {
public String getRelativeFilepathImpl() {
CxxWeaver weaver = getWeaverEngine();
+ // If file does not exist yet, return its path
+ if (!tunit.getFile().isFile()) {
+ return tunit.getFile().getPath();
+ }
+
return weaver.getApp().getRelativePath(weaver.getBaseSourceFolder(), tunit);
}
