Directory function

Moderator: Rathinagiri

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

Directory function

Post by Templar »

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: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Directory function

Post by gfilatov »

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: 3161
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 »

Thanks Grigory! Very usefull!!

Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3161
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 »

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

Serge
There's nothing you can do that can't be done...
Templar
Posts: 51
Joined: Sun Apr 01, 2018 5:37 pm
DBs Used: DBF

Re: Directory function

Post by Templar »

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