Page 1 of 1

Directory function

Posted: Fri Apr 06, 2018 10:46 am
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

Re: Directory function

Posted: Fri Apr 06, 2018 11:42 am
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:

Re: Directory function

Posted: Fri Apr 06, 2018 1:00 pm
by serge_girard
Thanks Grigory! Very usefull!!

Serge

Re: Directory function

Posted: Fri Apr 06, 2018 1:04 pm
by serge_girard
One small notice: file has to exist else you will get an RTE!

Serge

Re: Directory function

Posted: Sun Apr 08, 2018 8:29 pm
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