This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to set directory time stamps?


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".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]