2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
8 #ifdef HAVE_SYS_ERRNO_H
13 #include <sys/types.h>
15 #ifdef HAVE_SYS_MMAN_H
27 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(file)
31 DWORD ErrnoToLastError(int errno_num);
33 /***********************************************************************
34 * ReadFileEx (KERNEL32.)
38 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
40 DWORD dwNumberOfBytesTransfered,
41 LPOVERLAPPED lpOverlapped
44 BOOL WINAPI ReadFileEx(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
45 LPOVERLAPPED lpOverlapped,
46 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
49 FIXME("file %d to buf %p num %ld %p func %p stub\n",
50 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
51 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
55 /**************************************************************************
56 * SetFileAttributes16 (KERNEL.421)
58 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
60 return SetFileAttributesA( lpFileName, attributes );
64 /**************************************************************************
65 * SetFileAttributes32A (KERNEL32.490)
67 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
70 DOS_FULL_NAME full_name;
72 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
75 TRACE("(%s,%lx)\n",lpFileName,attributes);
76 if (attributes & FILE_ATTRIBUTE_NORMAL) {
77 attributes &= ~FILE_ATTRIBUTE_NORMAL;
79 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
80 lpFileName,attributes);
82 if(stat(full_name.long_name,&buf)==-1)
84 SetLastError(ErrnoToLastError(errno));
87 if (attributes & FILE_ATTRIBUTE_READONLY)
89 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
90 attributes &= ~FILE_ATTRIBUTE_READONLY;
94 /* add write permission */
95 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
97 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
99 if (!S_ISDIR(buf.st_mode))
100 FIXME("SetFileAttributes expected the file '%s' to be a directory",
102 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
104 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
106 FIXME("(%s):%lx attribute(s) not implemented.\n",
107 lpFileName,attributes);
108 if (-1==chmod(full_name.long_name,buf.st_mode))
110 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
111 SetLastError(ErrnoToLastError(errno));
118 /**************************************************************************
119 * SetFileAttributes32W (KERNEL32.491)
121 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
123 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
124 BOOL res = SetFileAttributesA( afn, attributes );
125 HeapFree( GetProcessHeap(), 0, afn );
130 /**************************************************************************
131 * SetFileApisToOEM (KERNEL32.645)
133 VOID WINAPI SetFileApisToOEM(void)
135 /*FIXME(file,"(): stub!\n");*/
139 /**************************************************************************
140 * SetFileApisToANSI (KERNEL32.644)
142 VOID WINAPI SetFileApisToANSI(void)
144 /*FIXME(file,"(): stub\n");*/
148 /******************************************************************************
149 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
152 * TRUE: Set of file functions is using ANSI code page
153 * FALSE: Set of file functions is using OEM code page
155 BOOL WINAPI AreFileApisANSI(void)
157 FIXME("(void): stub\n");