Bug 78336 - BASIC: The Basic Dir() statement is broken under certain conditions
Summary: BASIC: The Basic Dir() statement is broken under certain conditions
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.2.3.3 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-06 12:35 UTC by Ewald Anderl
Modified: 2016-10-11 09:54 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Screen shots and additional notes to reproduce problem (1.80 MB, application/vnd.oasis.opendocument.text)
2014-05-06 13:17 UTC, Ewald Anderl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ewald Anderl 2014-05-06 12:35:03 UTC
Problem description:

It appears that if the Dir() function in Basic hits any errors in accessing the directory, the results returned can not be relied upon. The function does not generate any errors back to the program and does not alert the user in any way. If there are any file names still in the queue from a prior call to the Dir() function, it will return those names. If not, it will return what appears as an empty directory. This occurs in both Windows and Linux environments (see “Table 6: Result summary for Linux, Dir() function“ and “Table 9: Result summary for Windows, Dir() function“ for screen shots, and 3.2.1, “Messages and debug output“ for additional discussion). 

Steps to reproduce:
1. Make call to Dir() for any path that would cause an error (e.g. /tmp/NoSuchPath)
2. Dir() will return empty string or phantom file names depending on prior calls to Dir() that succeeded.
3. ....

Current behavior:

Returns phantom file names in some cases.

Expected behavior:

Return no file names if directory not readable or accessible. Generating an error would be nice, but might break too many existing macros.

I will upload a document with screen-shots and additional info./

              
Operating System: All
Version: 4.2.3.3 release
Comment 1 Ewald Anderl 2014-05-06 13:17:14 UTC
Created attachment 98562 [details]
Screen shots and additional notes to reproduce problem
Comment 2 tommy27 2014-05-07 04:34:28 UTC
I add LibO BASIC expert to CC list.
Comment 3 Cor Nouws 2014-06-22 12:34:39 UTC
Hi Ewald,

(In reply to comment #0)

> 1. Make call to Dir() for any path that would cause an error (e.g.
> /tmp/NoSuchPath)
> 2. Dir() will return empty string or phantom file names depending on prior
> calls to Dir() that succeeded.

Indeed, this simple test shows it

Sub DirTst

 msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")
 msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/")
 msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")

End Sub

Results
 > empty
 > name1
 > name2

Do you know if this worked different before?
Cheers,
Cor
Comment 4 Ewald Anderl 2014-06-27 16:55:28 UTC
(In reply to comment #3)
> Hi Ewald,
> 
> (In reply to comment #0)
> 
> > 1. Make call to Dir() for any path that would cause an error (e.g.
> > /tmp/NoSuchPath)
> > 2. Dir() will return empty string or phantom file names depending on prior
> > calls to Dir() that succeeded.
> 
> Indeed, this simple test shows it
> 
> Sub DirTst
> 
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/")
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")
> 
> End Sub
> 
> Results
>  > empty
>  > name1
>  > name2
> 
> Do you know if this worked different before?
> Cheers,
> Cor

I do not know if this worked differently before. I am relatively new to LibreOffice and can only attest to behavior in version 4.2 and later; this behavior is present in all of these versions.

Sorry I can not be of more help with the history.
Comment 5 Julien Nabet 2015-10-18 11:51:37 UTC
On pc Debian x86-64 with LO Debian package 5.0.2.2, I don't reproduce this.
(I got only empty message).

Any update for you with recent LO version?
Comment 6 Xisco Faulí 2016-09-11 20:03:24 UTC Comment hidden (obsolete)
Comment 7 Xisco Faulí 2016-10-10 11:12:10 UTC Comment hidden (obsolete)
Comment 8 Cor Nouws 2016-10-11 09:54:00 UTC
(In reply to Cor Nouws from comment #3)

> Indeed, this simple test shows it
> 
> Sub DirTst
> 
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/")
>  msgbox dir("/home/cono/Documenten/DATA/TDF/Marketing/FOO/")
> 
> End Sub
> 
> Results
>  > empty
>  > name1
>  > name2

This now works fine in daily 20161009 > set as WorksForMe