2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
10 #ifdef HAVE_SYS_ERRNO_H
11 #include <sys/errno.h>
15 #include <sys/types.h>
17 #ifdef HAVE_SYS_MMAN_H
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(file
)
33 DWORD
ErrnoToLastError(int errno_num
);
35 /***********************************************************************
36 * ReadFileEx (KERNEL32.)
40 (CALLBACK
*LPOVERLAPPED_COMPLETION_ROUTINE
)(
42 DWORD dwNumberOfBytesTransfered
,
43 LPOVERLAPPED lpOverlapped
46 BOOL WINAPI
ReadFileEx(HFILE hFile
, LPVOID lpBuffer
, DWORD numtoread
,
47 LPOVERLAPPED lpOverlapped
,
48 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
)
51 FIXME("file %d to buf %p num %ld %p func %p stub\n",
52 hFile
, lpBuffer
, numtoread
, lpOverlapped
, lpCompletionRoutine
);
53 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
57 /**************************************************************************
58 * SetFileAttributes16 (KERNEL.421)
60 BOOL16 WINAPI
SetFileAttributes16( LPCSTR lpFileName
, DWORD attributes
)
62 return SetFileAttributesA( lpFileName
, attributes
);
66 /**************************************************************************
67 * SetFileAttributesA (KERNEL32.490)
69 BOOL WINAPI
SetFileAttributesA(LPCSTR lpFileName
, DWORD attributes
)
72 DOS_FULL_NAME full_name
;
74 if (!DOSFS_GetFullName( lpFileName
, TRUE
, &full_name
))
77 TRACE("(%s,%lx)\n",lpFileName
,attributes
);
78 if (attributes
& FILE_ATTRIBUTE_NORMAL
) {
79 attributes
&= ~FILE_ATTRIBUTE_NORMAL
;
81 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
82 lpFileName
,attributes
);
84 if(stat(full_name
.long_name
,&buf
)==-1)
86 SetLastError(ErrnoToLastError(errno
));
89 if (attributes
& FILE_ATTRIBUTE_READONLY
)
91 buf
.st_mode
&= ~0222; /* octal!, clear write permission bits */
92 attributes
&= ~FILE_ATTRIBUTE_READONLY
;
96 /* add write permission */
97 buf
.st_mode
|= 0600 | ((buf
.st_mode
& 044) >> 1);
99 if (attributes
& FILE_ATTRIBUTE_DIRECTORY
)
101 if (!S_ISDIR(buf
.st_mode
))
102 FIXME("SetFileAttributes expected the file '%s' to be a directory",
104 attributes
&= ~FILE_ATTRIBUTE_DIRECTORY
;
106 attributes
&= ~(FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_SYSTEM
);
108 FIXME("(%s):%lx attribute(s) not implemented.\n",
109 lpFileName
,attributes
);
110 if (-1==chmod(full_name
.long_name
,buf
.st_mode
))
112 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name
.long_name
);
113 SetLastError(ErrnoToLastError(errno
));
120 /**************************************************************************
121 * SetFileAttributesW (KERNEL32.491)
123 BOOL WINAPI
SetFileAttributesW(LPCWSTR lpFileName
, DWORD attributes
)
125 LPSTR afn
= HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName
);
126 BOOL res
= SetFileAttributesA( afn
, attributes
);
127 HeapFree( GetProcessHeap(), 0, afn
);
132 /**************************************************************************
133 * SetFileApisToOEM (KERNEL32.645)
135 VOID WINAPI
SetFileApisToOEM(void)
137 /*FIXME(file,"(): stub!\n");*/
141 /**************************************************************************
142 * SetFileApisToANSI (KERNEL32.644)
144 VOID WINAPI
SetFileApisToANSI(void)
146 /*FIXME(file,"(): stub\n");*/
150 /******************************************************************************
151 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
154 * TRUE: Set of file functions is using ANSI code page
155 * FALSE: Set of file functions is using OEM code page
157 BOOL WINAPI
AreFileApisANSI(void)
159 FIXME("(void): stub\n");