This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: How to set directory time stamps?
- To: Reinhard Dunkel <dunkel at tocsy dot chem dot utah dot edu>
- Subject: Re: How to set directory time stamps?
- From: jan dot dubois at ibm dot net (Jan Dubois)
- Date: Sun, 14 Dec 1997 21:02:54 +0100
- Cc: gnu-win32 at cygnus dot com
- References: <199712140407.VAA22002@tocsy.chem.utah.edu>
On Sat, 13 Dec 1997 21:07:51 -0700 (MST), you wrote:
>I am trying to port a program which depends on being able to update
>directory time stamps. Using GNU-Win32 b18 (with various patches
>applied), updating the time stamps of a plain file works. But I
>did not succeed to update the time stamps of a directory (Windows NT
>4.0 on Pentium II, FAT filesystem):
>
> bash-2.01$ mkdir TEST
> bash-2.01$ touch TEST
> touch: TEST: Permission denied
>
>The same problem appears for a C program using:
>
> utime(directoryName, NULL);
>
>(perror() returns something like "Is a directory".) NuTCRACKER fails
>too, Microsoft's "_utime()" doesn't work, but the MKS Toolkit "touch"
>command works flawlessly (...so it is do-able after all!). Somebody
>indicated to me that using "backup semantics to open the directory"
>and using "SetFileTime on that handle" should work. Well, I just
>entered the Microsoft World of programming. Part two sounds familiar,
>but what is "backup semantics"? Any help on solving the mystery of NT
>directory time stamp updates would be greatly appreciated!
Windows NT: You can obtain a handle to a directory by calling the
CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag set, as
follows:
hDir = CreateFile (
DirName,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL
);
You can pass a directory handle to the following SetFileTime function.
-Jan
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".