Recent

Author Topic: Linux: How to set a Folder Date/Time to Now?  (Read 321 times)

QEnnay

  • Full Member
  • ***
  • Posts: 129
Linux: How to set a Folder Date/Time to Now?
« on: June 14, 2025, 07:49:58 pm »
Hi,

Linux Mint + Lazarus-v4.0: all up to date

I need to force a base-folder Date to Now. I have searched, I checked several AI sites that suggested using fpSetDate etc, but I cannot get it to compile.

I already have sysUtils and baseUnix in the uses for other stuff, but it balks at any "fp...." stuff.

How's it done?

Code: Pascal  [Select][+][-]
  1.  
  2. procedure setFolderDate(aPath : string) ;
  3. begin
  4. //   example   aPath:='/media/userName/backDrv/home/userName/';
  5.  
  6.   setFolderPath(aPath);
  7.  
  8. end;
  9.  
  10.  

Thanks
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

cdbc

  • Hero Member
  • *****
  • Posts: 2251
    • http://www.cdbc.dk
Re: Linux: How to set a Folder Date/Time to Now?
« Reply #1 on: June 14, 2025, 08:02:48 pm »
Hi
You're looking for "Touch"  ...in FPC it's called FpUTime(): cint;
It can be found through 'baseunix'  8)
I think it'll work for directories too, by the looks of the source-code...
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

bytebites

  • Hero Member
  • *****
  • Posts: 719
Re: Linux: How to set a Folder Date/Time to Now?
« Reply #2 on: June 14, 2025, 08:12:05 pm »
Code: Pascal  [Select][+][-]
  1. filesetdate(afilename, DateTimeToFileDate(atime))

QEnnay

  • Full Member
  • ***
  • Posts: 129
Re: Linux: How to set a Folder Date/Time to Now?
« Reply #3 on: June 14, 2025, 08:51:15 pm »
Code: Pascal  [Select][+][-]
  1. filesetdate(afilename, DateTimeToFileDate(atime))

Awesome thanks, works a treat.
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

QEnnay

  • Full Member
  • ***
  • Posts: 129
Re: Linux: How to set a Folder Date/Time to Now?
« Reply #4 on: June 14, 2025, 08:55:58 pm »
You're looking for "Touch"  ...in FPC it's called FpUTime(): cint;
It can be found through 'baseunix'  8)

Hi Benny, thanks, I had previously been using "touch" but as with "fpAnything" they give a "not found" error, maybe just v4.0.

Bytebites offering has resolved it all. :)

Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

 

TinyPortal © 2005-2018