Skip to content

Commit d1e67c9

Browse files
committed
Handle relative rename targets in test filesystem
1 parent 2cd8ed7 commit d1e67c9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

maven/core-unittests/src/test/java/com/codename1/testing/TestCodenameOneImplementation.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,14 @@ public boolean exists(String file) {
19611961
public void rename(String file, String newName) {
19621962
TestFile f = fileSystem.remove(file);
19631963
if (f != null) {
1964-
fileSystem.put(newName, f);
1964+
String target = newName;
1965+
if (newName != null && !newName.contains("://") && !newName.startsWith("/")) {
1966+
int lastSlash = file.lastIndexOf('/');
1967+
if (lastSlash >= 0) {
1968+
target = file.substring(0, lastSlash + 1) + newName;
1969+
}
1970+
}
1971+
fileSystem.put(target, f);
19651972
}
19661973
}
19671974

0 commit comments

Comments
 (0)