wine bug? SetFileTime() error

Asked by Alexey Ermoshkin

install wine-1.0 from www.winehq.org OR from Ubuntu repository

SetFileTime() fail on hardy/gutsy, ok on dapper

0009:Call KERNEL32.SetFileTime(00000034,00000000,00000000,0032fd84) ret=00401358
0009:trace:ntdll:NtSetInformationFile (0x34,0x32fc78,0x32fc80,0x00000028,0x00000004)
0009: get_handle_fd( handle=0x34 )
0009: *fd* 0x34 -> 30
0009: get_handle_fd() = 0 { type=1, removable=0, access=00120116, options=00000050 }
0009:trace:ntdll:FILE_GetNtStatus errno = 14
0009:Ret KERNEL32.SetFileTime() retval=00000000 ret=00401358

### SetFileTime_test.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

BOOL SetFileToFixedTime(HANDLE hFile){
 FILETIME ft;
 SYSTEMTIME st;
 st.wYear=atoi("1992");
 st.wMonth=atoi("08");
 st.wDay=atoi("10");
 st.wHour=atoi("12");
 st.wMinute=atoi("31");
 st.wSecond=atoi("15");

 BOOL f;
 printf("%02d/%02d/%d %02d:%02d\n", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute);
 SystemTimeToFileTime(&st, &ft); // converts to file time format
 f = SetFileTime(hFile, // sets last-write time for file
  (LPFILETIME) NULL, (LPFILETIME) NULL, &ft);
 return f;
}

int main(void){

HANDLE hFile;
char * csFileName = "C:\\setfiletotime.test";
char WriteTime[255];
hFile = CreateFile( csFileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

  if (SetFileToFixedTime(hFile)) {
    printf("SetFileWriteTime: Ok\n");
  } else {
    printf("SetFileWriteTime: Bug\n");
  }

CloseHandle( hFile );
 return 0;
}

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu wine Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dan Kegel (dank) said :
#1

Your test program has a bug: it forgot to actually create the test file, and it forgot to check the return value from CreateFile. If I change the CreateFile call to

hFile = CreateFile( csFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTR
IBUTE_NORMAL, NULL );
if (hFile == INVALID_HANDLE_VALUE) {
  printf("can't create file\n");
  exit(1);
}

it works for me with current wine from git.

Can you help with this problem?

Provide an answer of your own, or ask Alexey Ermoshkin for more information if necessary.

To post a message you must log in.