Exit Posted February 26, 2013 Share Posted February 26, 2013 When using Filedelete() function on ADS files, Filedelete fails (Return=0), but @error is set to 0 (no error) and the ADS stream is not deleted. Here a reproducer: _Try("~temp.txt:ADS") _Try("~temp.txt") Func _Try($sFilename) FileWriteLine($sFilename, "This is a Test") MsgBox(262144, $sFilename, "Filename: " & $sFilename & @LF & @LF & "File before FileDelete():" & @LF & FileRead($sFilename)) $rc = FileDelete($sFilename) MsgBox(262144, $sFilename, "If $rc is zero (no Success), @error should be NOT zero. (in my opinion)" & @LF & @LF & _ "Filename: " & $sFilename & @LF & @LF & "Filedelete() return values $rc: " & $rc & " @error: " & @error & @LF & @LF & _ @LF & "File after FileDelete():" & @LF & FileRead($sFilename), 0) EndFunc ;==>_Try Autoit should set @error to 1 (nonzero) Is it a bug or a feature ? ADS = Alternate Data Stream (Google is your friend ) App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
KaFu Posted February 26, 2013 Share Posted February 26, 2013 I guess it's a bug , had a similar issue in the past and solved it this way: OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Exit Posted February 27, 2013 Author Share Posted February 27, 2013 Yes, it is a bug in Autoit.1. ADS files will never be deleted.2. FileDelete() always sets @error to 0. Even on failure. (ok, helpfile says nothing about @error)I wrote _FileDelete() function based on Yashied's _WinAPI_DeleteFile()and a reproducer:_Try("~temp.txt:ADS") _Try("~temp.txt") Func _Try($sFilename) FileWriteLine($sFilename, "This is a Test") $Return = FileDelete($sFilename) $Error = @error ConsoleWrite(@lf&"Filename: " & $sFilename & @LF & "Filedelete() $Return: " & $Return & " @error: " & @error & @LF) If $Return+$Error= 0 Then ConsoleWrite("*** Bug *** ==> If $Return=0 (no Success), @error should be 1 " & @LF ) $Return = _FileDelete($sFilename) $Error = @error ConsoleWrite("_Filedelete() $Return: " & $Return & " @error: " & @error & @LF& @LF) EndFunc ;==>_Try Func _FileDelete($sFile) $sFile = DllCall('kernel32.dll', 'int', 'DeleteFileW', 'wstr', $sFile) Return SetError(Not $sFile[0], 0, $sFile[0]) EndFunc ;==>_FileDeleteHere the console output:Filename: ~temp.txt:ADS Filedelete() $Return: 0 @error: 0 *** Bug *** ==> If $Return=0 (no Success), @error should be 1 _Filedelete() $Return: 1 @error: 0 Filename: ~temp.txt Filedelete() $Return: 1 @error: 0 _Filedelete() $Return: 0 @error: 1The last _FileDelete fails since previous FileDelete() did the job already.I modified TRAC #2221 Feature Request and added TRAC #2321 Feature Request App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now