as3hx icon indicating copy to clipboard operation
as3hx copied to clipboard

When 2 .as files have a similar file name, the second one gets overwritten without a warning

Open mastef opened this issue 8 years ago • 1 comments
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.

mastef avatar Oct 20 '17 06:10 mastef

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?

mastef avatar Oct 20 '17 07:10 mastef