PB 5.11 - RenameFile reports success although it failed
Posted: Wed Jul 31, 2013 1:40 pm
In case you're using 'RenameFile' to move a file from one drive to another and the destination filename includes forbidden characters ( \ / : * ...) the 'RenameFile' command reports success although it failed - in the end the source file has been deleted and the destination file is not available.... perfect data loss...
I'd expect 'RenameFile' to fail as it does when src and dest-drive are equal.
I get this result:
I get the error independent of ASCII or UNICODE compiler setting.
Tried it with Purebasic 5.11 x86 on Windows 7x64
I'd expect 'RenameFile' to fail as it does when src and dest-drive are equal.
Code: Select all
Define Filename.s="c:\TMP\test.txt"
Define NewFilename.s="d:\TMP\test:invalidfilename.txt"
If CreateFile(0, Filename)
WriteString(0, "TEST")
CloseFile(0)
Debug "Filesize >"+Str(FileSize(Filename))+"<"
If RenameFile(Filename, NewFilename)
Debug "RenameFile successfull! New Filesize >"+Str(FileSize(NewFilename))+"<"
Else
Debug "Error!! RenameFile failed"
EndIf
Else
Debug "Createfile >"+Filename+"< failed!"
EndIfAnd in the destination dir there is a file named 'test' with a size of 0 Bytes.[14:36:35] Filesize >4<
[14:36:35] RenameFile successfull! New Filesize >-1<
I get the error independent of ASCII or UNICODE compiler setting.
Tried it with Purebasic 5.11 x86 on Windows 7x64