haxe

sys.io.File.saveContent and sys.FileSystem.deleteFile failing for unknown reasons


i have encountered some strange issues when it comes to deleting or overwriting files in all haxe/haxeflxiel projects, it used to work fine then suddenly stopped working a while ago, all of them are compiled to C++ (windows)

all of these issues have occured in both haxe versions 4.1.5 and 4.3.1

firstly i made a program that uses lime.ui.FileDialog to select a folder to then recursively go through and delete files that meet certain criteria, in this case it's any file ending in a ~. the program then checks every single file in the folder and any subfolders and adds the path of any valid files into an array. once it has searched all folders it will then prompt a confirmation to delete the files and increment over the array and use sys.FileSystem.deleteFile to delete them then remove the path form the array if successful and displays weather the file was deleted, if it fails to delete a file it is left in the array and at the end will prompt if it should try again.

the issue is that it will always fail to delete files with the error Could not delete (path) with (path) being the path of the file, even if sys.FileSystem.exists is used on the path it will return that it exists, these files can still be deleted using the file explorer just fine just not throught the program.

secondly there is a game im working on in haxeflxiel with custom tools to make dialogue that i can once again use lime.ui.FileDialog to choose a path to save the data as a .json to using sys.io.File.saveContent. when giving the file a unique name it works fine but if i try to save it with the same name as another file in the same folder (and prompting the "this file alreaddy exists" popup) it will never succeed, giving the error [file_open,(path)] with (path) being the path to the file. strangely enough sys.io.File.saveContent is used in other areas and works just fine, sys.FileSystem.deleteFile is also used and again, works fine here also.

none of these examples use any haxeflxiel related libraries during the segments that have issues. also i know that the path returned by lime.ui.FileDialog uses backslashes which afaik don't work so i replace them with forward slashes.


Solution

  • ok so it turns out it was my antivirus, i thought i had excluded the programs from being blocked like this but nope, im still confused why it suddenly started doing this when it never did before.