as3hx
as3hx copied to clipboard
When 2 .as files have a similar file name, the second one gets overwritten without a warning
trafficstars
source AS3 file scripts/sortBtn_Cont.as
target HX file: scripts_hx/SortBtnCont.hx
source AS3 file: scripts/sortBtnCont.as
target HX file: scripts_hx/SortBtnCont.hx
This collision should produce an error. Possibly add a sys.FileSystem.exists() check on the target HX file before writing.
A change like this helped :
var name = out.addTrailingSlash() + Writer.properCase(f.substr(0, -3), true) + ".hx";
+ var i = 0;
+ while(sys.FileSystem.exists(name)) {
+ i++;
+ name = out.addTrailingSlash() + Writer.properCase(f.substr(0, -3), true) + i + ".hx";
+ }
Sys.println("target HX file: " + name);
The classname doesn't match the new filename though, but this at least would throw an error on build - instead of having a missing file.
source AS3 file: scripts/sortBtn_Cont.as
target HX file: scripts_hx/SortBtnCont.hx
source AS3 file: scripts/sortBtnCont.as
target HX file: scripts_hx/SortBtnCont1.hx
@SlavaRa Would you like me to PR this, or any other ideas how to improve such a collision?