PRB: _dos_setftime() Fails to Set Date & Time for Network File

ID: Q68797

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50

MS-DOS                      | OS/2            | WINDOWS
kbprg kbprb

The information in this article applies to:

SYMPTOMS

The _dos_setftime() function is used to set the date and time of a file. If the file is on a local drive, the function behaves as expected; however, if the file resides on a network drive, the date and time returned by subsequent _dos_getftime() will not return the new values.

The date and time of the file on the network will be set. However, _dos_getftime() will not recognize the change until the file has been closed and re-opened.

STATUS

The C run-time library is performing as expected. The problem is a limitation of either the operating system or the network software.

MORE INFORMATION

Sample Code

/* Compile options needed: none
*/ 

#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <fcntl.h>

void main(void)
{
    int fh;
    unsigned int new_date = 0x184f;     /*   2/15/92   */ 
    unsigned int new_time = 0x48e0;     /*   9:07 AM   */ 
    unsigned int old_time, old_date;

   if( _dos_open("test.dat", O_RDONLY, &fh) != 0)
      exit(1);

   _dos_getftime( fh, &old_date, &old_time );
   system("dir test.dat");

   _dos_setftime( fh, new_date, new_time );
   system("dir test.dat");

   _dos_close( fh );
   if( _dos_open("test.dat", O_RDONLY, &fh) != 0)
      exit(1);

   printf("\nAfter closing and reopening the file.\n");
   _dos_getftime( fh, &old_date, &old_time );
   system("dir test.dat");
}

Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50 KBCategory: kbprg kbprb KBSubcategory: CRTIss Keywords : kb16bitonly

Last Reviewed: July 18, 1997