Directory function

Moderator: Rathinagiri

Post Reply
Templar
Posts: 29
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Directory function

Post by Templar » Fri Apr 06, 2018 10:46 am

The Clipper "DIRECTORY()" command used to display the date a folder (in those far-off days still called a Directory...) was created. Now it returns the date modified instead. Is there any way to get back to the creation date? Windows7 defaults to changing the folder modification date whenever one of the files within it changes: arguably one of the most stupid things even Micrsoft could have dreamed up. A bit like saying my car has been modified any time any of the passengers change, but don't get me started on Microsoft stupidities...)
Templar

User avatar
gfilatov
Posts: 557
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Directory function

Post by gfilatov » Fri Apr 06, 2018 11:42 am

Templar wrote:
Fri Apr 06, 2018 10:46 am
The Clipper "DIRECTORY()" command used to display the date a folder (in those far-off days still called a Directory...) was created. Now it returns the date modified instead. Is there any way to get back to the creation date? Windows7 defaults to changing the folder modification date whenever one of the files within it changes: arguably one of the most stupid things even Micrsoft could have dreamed up. A bit like saying my car has been modified any time any of the passengers change, but don't get me started on Microsoft stupidities...)
Hi Templar,

Yes, it is possible.
There is the function FileStats() in the Harbour contrib library XHB.

Please take a look for a simple sample below:

Code: Select all

#include "minigui.ch"

//***************************************************************************

PROCEDURE Main

DEFINE WINDOW wMain ;
AT 100,200 WIDTH 230 HEIGHT 100 ;
TITLE "Demo" ;
MAIN ;
NOMAXIMIZE NOSIZE

DEFINE BUTTON btOpen
ROW 10
COL 20
WIDTH 80
HEIGHT 50
CAPTION 'Get Stats'
ACTION OpenFile()
END BUTTON

DEFINE BUTTON btClose
ROW 10
COL 120
WIDTH 80
HEIGHT 50
CAPTION 'Close'
ACTION wMain.Release
END BUTTON

END WINDOW

ACTIVATE WINDOW wMain

RETURN

//***************************************************************************

PROCEDURE OpenFile()

      LOCAL cTxt := ""
      LOCAL cFileName := "DEMO.PRG"
      LOCAL cFileAttr  , nFileSize
      LOCAL dCreateDate, nCreateTime
      LOCAL dChangeDate, nChangeTime

      FileStats( cFileName, @cFileAttr  , @nFileSize  , ;
                              @dCreateDate, @nCreateTime, ;
                              @dChangeDate, @nChangeTime  )

      cTxt += "File Name : " + cFileName + CRLF
      cTxt += "Attributes: " + cFileAttr + CRLF
      cTxt += "File Size : " + xChar( nFileSize ) + CRLF
      cTxt += "Created   : " + xChar( dCreateDate ) + " - " + TString( nCreateTime ) + CRLF
      cTxt += "Changed   : " + xChar( dChangeDate ) + " - " + TString( nChangeTime )

      MsgInfo( cTxt, "File statistiscs" )

RETURN
Hope that useful :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
serge_girard
Posts: 2093
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Directory function

Post by serge_girard » Fri Apr 06, 2018 1:00 pm

Thanks Grigory! Very usefull!!

Serge

User avatar
serge_girard
Posts: 2093
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Directory function

Post by serge_girard » Fri Apr 06, 2018 1:04 pm

One small notice: file has to exist else you will get an RTE!

Serge

Templar
Posts: 29
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: Directory function

Post by Templar » Sun Apr 08, 2018 8:29 pm

Hello Drigory
Thanks for that. Looks useful. I have not yet got into the other library functions, so maybe I will have to start on that. It looks like being a big project though!
Templar

Post Reply