Not really TC, but almost: ReDate Directories

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Not really TC, but almost: ReDate Directories

Post by *eitang »

Hi,

I am a Delphi (databases) programmer, and am trying to write a program that will recursively re-date (and re-time) all directories under the current one to the date of the youngest file inside them.

This is needed as TC551 will not keep directory timestamp when copying. (It does when moving).

I wrote Christian about it and he sent me a very hieroglyphic D5 command, but I can't (=am not able to) use it.

Here it is (I assume it is not a secret, Christian):

------------------

f:=CreateFile(dirname,
GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE,
nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL or FILE_FLAG_BACKUP_SEMANTICS,0);
if (f<>invalid_handle_value) then begin
setfiletime(f,nil,nil,@newfiletime);
CloseHandle(f);
end;
------------------

A) Is there such a program?
B) Anybody can help with a sort of "sample"?

TIA,

Eitan. (eitang@wanadoo.fr)
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13073
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Hi,
That Delphi command only works under NT and higher, for W9x you must use the DOS interrupt approach. I tried to change the dates of directories, too (if you understand German http://thehacker.host.sk/addtime/addtimethread.html ), but failed, despite excellent documentation ( http://thehacker.host.sk/myfiles/wc/ and there tech60.zip ). I can send you a little program in C tomorrow (I don't have it here) to show you how far I've come - maybe we can find a solution together.

HTH
Roman
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Roman,

Thank you for the kind offer.

I speak no German at all, unfortunately. I also speak no "C" <g>

If you still want I'd be delighted to work on the program with you.

Eitan.

P.S. We can switch to e-mail: eitang@wanadoo.fr
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13073
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

IMHO it might be profitable for other users who'd like to learn something to follow the discussion in case we get somewhere.

I personally don't speak that much C either, but you'll understand the program, it's very short and simple (and commented!). You can find it at http://thehacker.host.sk/myfiles/ and there dirdate.zip . In that program I am trying to get the handle of a directory (to later use it to get the timestamp of the dir) but I always get the error "Invalid handle" instead of the handle itself and that's where I didn't know further.
Did you download tech60.zip? Because without that we won't move on, either.
(BTW: Do you have a C compiler? I am sure it would be possible to do this in Pascal, too, but I haven't tried it yet.)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
eitang
Senior Member
Senior Member
Posts: 250
Joined: 2003-05-19, 20:08 UTC
Location: France
Contact:

Post by *eitang »

Yes, I got tech60 - seems really great and thank you for that. As for DirDate - I understood nothing in it :-(

Eitan.

No, I have no C compiler.
Best Wishes,

Eitan Gilboa (License #: 17011)
URL: https://eitang.pagesperso-orange.fr/
User avatar
Hacker
Moderator
Moderator
Posts: 13073
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Oh well, then I guess you have to try it using Delphi and null-terminated strings.

Code: Select all

#include <dos.h>
#include <stdio.h>
#include <string.h>
These are just standard C includes, something like the Delphi "uses" clause.

Code: Select all

void main()
This is where the main program starts.

Code: Select all

{
Just like BEGIN.

Code: Select all

  union REGS regs;
  struct SREGS sregs;
  char s[80];
  int value;
This is the definition of variables, the first two ones are used for register handling, third one is a sort of string and "value" is for chceking the return value of a function.

Code: Select all

  strcpy(s, "c:\\test"); // puts the string - "c:\test",0 - into s
  printf("\n%s", s);           // check it
  regs.h.ah = 0x3d;            // select function "open handle"
  regs.h.al = 0;               // open for: 0 - read, 1 - write, 2 - both
  regs.x.dx = FP_OFF(s);       // set the filename's address in memory (offset part)
  sregs.ds = FP_SEG(s);        // set the filename's address in memory (segment part)
  value = intdosx(&regs, &regs, &sregs); // call INT 21H
                                         // and get the value - either error
                                         // code or file handle
  printf("\n%d", value);                 // check what we got
                                         // 2 means File not found
                                         // 3 means Path not found
                                         // 5 means Access denied
                                         // 6 means Invalid handle
                                         //   but what does that mean?
                                         //   We want to GET a handle...

  value = regs.x.ax;                     // just a check to see if the
  printf("\n%d", value);                 // value that intdosx returns is
                                         // the same as stored in AX
The code should not be THAT difficult to understand, nay commented.
Just ask.

Roman
Post Reply