Modify

Opened 11 years ago

Closed 11 years ago

#2904 closed Bug (No Bug)

FileOpen does NOT return an error when path is invalid.

Reported by: ILLBeBack Owned by:
Milestone: Component: AutoIt
Version: 3.3.12.0 Severity: None
Keywords: FileOpen Cc:

Description

The FileOpen function does not return an @error value of –1 when the path is invalid. The following script demonstrates this by using multiple colons in the path.

#include <FileConstants.au3>

ConsoleWrite("Define an InValid path for a file name by use of multiple colons." & @LF)
Local $sFile = "d:::\xxxx\Test.txt"
ConsoleWrite("$sFile=" & $sFile & @LF)

Local $h1 = FileOpen($sFile, $FO_OVERWRITE + $FO_CREATEPATH)
If @error = -1 Then
    ConsoleWrite($sFile & " is an INvalid filename. " & @LF)
    $sFile = @ScriptDir & "\TVLister.xml"
Else
    ConsoleWrite($sFile & " is a valid filename. " & @LF)
    FileClose($h1)
EndIf

ConsoleWrite("FileExists(" & $sFile & ")=" & FileExists($sFile) & @LF)
If FileExists($sFile) Then FileDelete($sFile)

Exit

Tested in v3.3.12.0 and v3.3.13.19

Attachments (0)

Change History (2)

comment:1 by MHz, 11 years ago

@error will always be 0 after use of FileOpen as FileOpen does not set @error. It is the return value of $h1 that is tested with -1 as a check for failure.

Note, the word "error" is not the same as the macro "@error" as mentioned in the help file in the failure section.

comment:2 by BrewManNH, 11 years ago

Resolution: No Bug
Status: newclosed

This isn't a bug, the function sets the return value to -1, it does not set @error.

You should be posting these "bug" reports to the forum before posting them here, it would have been explained to you without us having to go through the effort of closing the track tickets.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.