Forum > LCL

Getting the Directory'Folder date?

(1/2) > >>

QEnnay:
Linux Mine+Mate, Laz-2.0.12

My backup modifies the base-folder-path date on the target drive to the current date using


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  strFpSystem:='touch ' ...  fpSystem(strFpSystem); 
I would like to read that same folder Date in an AfterScroll function for a database.

I have searched and found, **DirectoryAge()** here, but the compiler spits it out.

How can I get that Directory/Folder age to display in a Label.Caption by any Lazarus/FPC/Linux method?

The FPC Wiki on **fpSystem** is way too cryptic for my old brain. :)


KodeZwerg:
FileAge() should deliver what you want, maybe needs to be converted with FileDateToDateTime() afterwards but i am extreme unskilled with non-windows OS.

MarkMLl:
Since you're already using fpSystem() one the obvious way would be to use something like


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---~$ ls -ld Downloads # or alternatively ~$ ls -d --full-time Downloads 
and parse the output. However I think that you might find fpStat() a bit more immediately useful since the dates will be in machine format.

I don't know whether you can streamline that touch by using something like FileSetDate(). In any event, I suggest that you could usefully familiarise yourself with the documentation at https://www.freepascal.org/docs.html , noting that this is /documentation/ rather than just "a wiki" or some random website (I'd like to think that I'm stating the obvious, but you'd be surprised how many people have at best a dim appreciation of the distinction :-)

MarkMLl

Fred vS:
Hello.

You may use FpStat from baseunix unit:
https://www.freepascal.org/docs-html/rtl/baseunix/fpstat.html


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program fstat_date; uses BaseUnix; var     info : stat; begin   if fpstat ('/home/you/',info)<>0 then  // in Unix a directory is a file     begin       writeln('Fstat failed. Errno : ',fpgeterrno);       halt (1);     end;   writeln ('ctime   : ',info.st_ctime); //  File creation time   writeln ('ctime_nsec   : ',info.st_ctime_nsec); // File creation time with nanosecond precision    writeln ('atime   : ',info.st_atime); //  Last file access time   writeln ('atime_nsec   : ',info.st_atime_nsec); // Access time with nanosecond precision     writeln ('mtime   : ',info.st_mtime); //  Last file modification time   writeln ('mtime_nsec   : ',info.st_mtime_nsec); // Last file modification time e with nanosecond precision end.

QEnnay:

--- Quote from: KodeZwerg on September 14, 2022, 06:01:14 pm ---FileAge()

--- End quote ---

Thanks, I had tried that but it returns -1. Also I read where the wiki stated it would not work on Directories, but I had already tried that anyway.

Navigation

[0] Message Index

[#] Next page

Go to full version