seach a directory

Posted by HachDev on 03-Mar-2015 09:00

Hi, how can i knwo if a sub-directory exists in a directory using progress :

example   : "C:\X\Y" exists in "C:\X\" 

All Replies

Posted by Peter Judge on 03-Mar-2015 09:06

Look at the FILE-INFO handle.
 
    FILE-INFO:FILE-NAME = 'c:\x\y'.
 
If FILE-INFO:FULL-PATHNAME <> ? then it exists.
 
Alternatively, you can look at the INPUT-FROM command to read all a directory's entries.
 
 
[collapse]
From: HachDev [mailto:bounce-HachDev@community.progress.com]
Sent: Tuesday, 03 March, 2015 10:02
To: TU.OE.Development@community.progress.com
Subject: [Technical Users - OE Development] seach a direcrtory
 
Thread created by HachDev

Hi, how can i knwo if a sub-directory exists in a directory using progress :

example   : "C:\X\Y" exists in "C:\X\" 

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by bronco on 03-Mar-2015 09:10

but then 'y' can be a file as well ;-)

I would check:

IF index("D", FILE-INFO:FILE-TYPE) > 0 then

 /* it exists */

Posted by bronco on 03-Mar-2015 09:13

err:

IF index(FILE-INFO:FILE-TYPE, "D") > 0 THEN...

Posted by bronco on 03-Mar-2015 09:17

Oh what a joy it would have been if the parameter order of the INDEX and LOOKUP function would be the same...

Posted by Peter Judge on 03-Mar-2015 09:23

PLUS ONE^INFINITY
 
(sorry, but that's been bothering me for about 15 years now ;)
 
[collapse]
From: bronco [mailto:bounce-bfvo@community.progress.com]
Sent: Tuesday, 03 March, 2015 10:18
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] seach a direcrtory
 
Reply by bronco

Oh what a joy it would have been if the parameter order of the INDEX and LOOKUP function would be the same...

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Roger Blanchard on 03-Mar-2015 09:28

Another option is to use .NET. I know in 10.2B the System.IO.FileInfo was much faster than the ABL FILE-INFO

oDirectory = NEW System.IO.DirectoryInfo ("FolderName").

IF oDirectory:EXISTS THEN

Posted by Roger Blanchard on 03-Mar-2015 09:30

That is of course if running on windows.

Posted by Matt Baker on 03-Mar-2015 09:33

 
The first rule of optimization is “don’t do it”.  Don’t switch to .NET like this just for performance.   If the API is better (which it is) or more complete (which it is) and .NET is allowed for your app (up to you), then it makes sense (maybe). 
 
The existing ABL directory functionality works with both unix and windows.
 
mattB
 
[collapse]
From: rblanchard [mailto:bounce-rblanchard@community.progress.com]
Sent: Tuesday, March 03, 2015 10:30 AM
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] seach a direcrtory
 
Reply by rblanchard

Another option is to use .NET. I know in 10.2B the System.IO.FileInfo was much faster than the ABL FILE-INFO

oDirectory = NEW System.IO.DirectoryInfo ("FolderName").

IF oDirectory:EXISTS THEN

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by bronco on 03-Mar-2015 11:35

[quote user="Peter Judge"]

PLUS ONE^INFINITY

[/quote]

Of course 1^infinity = 1

But that's completely besides the point :-)

(sorry, couldn't resist)

Posted by gabriel.lucaciu on 04-Mar-2015 01:36

You can even check more on the file-type, like the following
H The file is hidden.
R The file is readable.
W The file is writeable.
...

Posted by Roger Blanchard on 04-Mar-2015 06:49

This is why I stated you must be on Windows. If not then don’t even think about using .NET.
 
As far as the “don’t do it”…not sure I agree. We had a performance issue with some internal application logging and tracked it back to FILE-INFO. The FILE-INFO would take 15ms where the .NET FileInfo class would take 1ms to give us the same info. For us it was a no brainer not just for the performance but the API.
 
I guess it really depends on the use case.
 
Roger Blanchard
 
[collapse]
From: Matt Baker [mailto:bounce-mbaker@community.progress.com]
Sent: Tuesday, March 03, 2015 10:33 AM
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] seach a direcrtory
 
Reply by Matt Baker
 
The first rule of optimization is “don’t do it”.  Don’t switch to .NET like this just for performance.   If the API is better (which it is) or more complete (which it is) and .NET is allowed for your app (up to you), then it makes sense (maybe). 
 
The existing ABL directory functionality works with both unix and windows.
 
mattB

[/collapse]

Posted by Thomas Mercer-Hursh on 04-Mar-2015 09:43

The difference between 15ms and 1ms may seem like a lot and could be significant if you were executing it in a tight loop thousands of times and doing little other work, but if there is UI or DB access or whatever in that loop, then you will never see that difference.

Posted by Roger Blanchard on 04-Mar-2015 09:48

It was significant in our case which is why we switched to FileInfo class.
 
Roger Blanchard
 
[collapse]
From: Thomas Mercer-Hursh [mailto:bounce-tamhas@community.progress.com]
Sent: Wednesday, March 04, 2015 10:45 AM
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] seach a directory
 
Reply by Thomas Mercer-Hursh

The difference between 15ms and 1ms may seem like a lot and could be significant if you were executing it in a tight loop thousands of times and doing little other work, but if there is UI or DB access or whatever in that loop, then you will never see that difference.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

This thread is closed