xml2 icon indicating copy to clipboard operation
xml2 copied to clipboard

Trying to read an invalid .xml file makes it so that the file cannot be deleted

Open billdenney opened this issue 1 year ago • 2 comments

When trying to read an invalid .xml file, I cannot delete the. I think that this is because the connection remains open. If important, this happens on Windows (I've not tested other operating systems).

filename <- tempfile(fileext = ".xml")
bad_xml_file <- writeLines("<a>", con = filename)
file.remove(filename)
#> [1] TRUE

filename <- tempfile(fileext = ".xml")
bad_xml_file <- writeLines("<a>", con = filename)
xml2::read_xml(filename)
#> Error in read_xml.character(filename): EndTag: '</' not found [74]
file.remove(filename)
#> Warning in file.remove(filename): cannot remove file 'C:
#> \Users\wdenn\AppData\Local\Temp\RtmpQR65s3\file5e74463b35d8.xml', reason
#> 'Permission denied'
#> [1] FALSE

Created on 2022-10-29 with reprex v2.0.2

billdenney avatar Oct 29 '22 20:10 billdenney