Discussion:
Function DirectoryRecurse change current directory
Marcos Gambeta
2009-02-17 23:36:58 UTC
Permalink
Hi all,

After a call to function DirectoryRecurse, the current directory change.

Example:

procedure main ()
? "before"
? curdir()
a := directoryrecurse("c:\somedir")
?
? "after"
? curdir()
inkey(0)
return


With xharbour 1.0.0, current directory don't change.


Regards,
Marcos Gambeta
Enrico Maria Giordano
2009-02-18 08:12:52 UTC
Permalink
-----Messaggio Originale-----
Da: "Marcos Gambeta" <marcos.gambeta-/E1597aS9LRfJ/***@public.gmane.org>
A: "xHarbour-Developers" <xharbour-developers-5NWGOfrQmneRv+***@public.gmane.org>
Data invio: mercoledì 18 febbraio 2009 0.36
Oggetto: [xHarbour-developers] Function DirectoryRecurse change
currentdirectory
Post by Marcos Gambeta
Hi all,
After a call to function DirectoryRecurse, the current directory change.
procedure main ()
? "before"
? curdir()
a := directoryrecurse("c:\somedir")
?
? "after"
? curdir()
inkey(0)
return
With xharbour 1.0.0, current directory don't change.
I just tried your sample using latest xHarbour from CVS and found no problem
(BCC55, Windows XP).

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic
Marcos Gambeta
2009-02-18 18:15:00 UTC
Permalink
Post by Enrico Maria Giordano
I just tried your sample using latest xHarbour from CVS and found no
problem (BCC55, Windows XP).
Try this:

procedure main ()

? "current"
? curdir()

makedir("dir1")

dirchange("dir1")

? "before"
? curdir()

a := directoryrecurse("c:\xhb\bin") // use any folder here with some
files

?

? "after"
? curdir()

inkey(0)

return


Regards,
Marcos Gambeta
Marcos Gambeta
2009-02-18 22:23:53 UTC
Permalink
Post by Marcos Gambeta
current
XHARBOUR
before
XHARBOUR\dir1
after
XHARBOUR\dir1
Enrico,

Thanks!

Is very strange, but in my tests the directory change. I am using
Windows Vista.

I found this entry in Harbour changelog:

2008-07-25 15:24 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/xhb/Makefile
* harbour/contrib/xhb/common.mak
+ harbour/contrib/xhb/dirrec.prg
+ added DirectoryRecurse() function. It's not exactly xHarbour
compatible as I wanted at the beginning. But when I begin
to carefully check what xHarbour exactly does then I dropped
the strict compatibility due to problems with xHarbour
implementation which have to be fixed. I left this note in the
dirrec.prg header:
This implementation uses different rules then xHarbour one.
It does not change current drive or current directory so
unlike the xHarbour version it's MT safe.
It also returns relative paths which are more similar to
DIRECTORY() function results so they can be easy used
directly in other code, f.e. to create archive without
absolute paths. Please note that user can easy convert
relative paths to absolte ones by simple adding curdir()
and/or cPath parameter passed to DirectoryRecurse() but
reverted conversion may not be possible in some cases.
The 3-rd xHarbour parameter <lCaseMach> is ignored because
harbour uses platform native rules to check filename mask
respecting SET FILECASE and SET DIRCASE settings.
xHarbour does not add "D" to attribute list used for directory
tree scanning so user always have to add it manually and later
it ignores it so it's not possible to extract file list with
directories entries. In Harbour it's fixed.

* harbour/source/rtl/philes.c
+ added hb_osFileMask()

* harbour/source/rtl/direct.c
% minor optimization


Time to try a clean cvs and another OS.


Regards,
Marcos Gambeta
Enrico Maria Giordano
2009-02-19 07:51:49 UTC
Permalink
-----Messaggio Originale-----
Da: "Marcos Gambeta" <marcos.gambeta-/E1597aS9LRfJ/***@public.gmane.org>
A: "xHarbour-Developers" <xharbour-developers-5NWGOfrQmneRv+***@public.gmane.org>
Data invio: mercoledì 18 febbraio 2009 23.23
Oggetto: Re: [xHarbour-developers] Function
DirectoryRecursechangecurrentdirectory
Post by Marcos Gambeta
Is very strange, but in my tests the directory change. I am using
Windows Vista.
I didn't try with Vista. I'm using XP. Anyway, I don't like how
DirectoryRecurse() works. It is very slow even if the directory contains
only one file and no subdirectories.
I don't know if it is related to your problem, though.

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic

Enrico Maria Giordano
2009-02-18 21:54:18 UTC
Permalink
-----Messaggio Originale-----
Da: "Marcos Gambeta" <marcos.gambeta-/E1597aS9LRfJ/***@public.gmane.org>
A: "xHarbour-Developers" <xharbour-developers-5NWGOfrQmneRv+***@public.gmane.org>
Data invio: mercoledì 18 febbraio 2009 19.15
Oggetto: Re: [xHarbour-developers] Function DirectoryRecurse
changecurrentdirectory
Post by Marcos Gambeta
procedure main ()
? "current"
? curdir()
makedir("dir1")
dirchange("dir1")
? "before"
? curdir()
a := directoryrecurse("c:\xhb\bin") // use any folder here with some
files
?
? "after"
? curdir()
inkey(0)
return
current
XHARBOUR
before
XHARBOUR\dir1

after
XHARBOUR\dir1

EMG

--
EMAG Software Homepage: http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page: http://www.emagsoftware.it/emgmusic
Loading...