2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
11 #include <sys/types.h>
23 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(file)
27 DWORD ErrnoToLastError(int errno_num);
29 /***********************************************************************
30 * ReadFileEx (KERNEL32.)
34 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
36 DWORD dwNumberOfBytesTransfered,
37 LPOVERLAPPED lpOverlapped
40 BOOL WINAPI ReadFileEx(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
41 LPOVERLAPPED lpOverlapped,
42 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
45 FIXME("file %d to buf %p num %ld %p func %p stub\n",
46 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
47 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
51 /**************************************************************************
52 * SetFileAttributes16 (KERNEL.421)
54 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
56 return SetFileAttributesA( lpFileName, attributes );
60 /**************************************************************************
61 * SetFileAttributes32A (KERNEL32.490)
63 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
66 DOS_FULL_NAME full_name;
68 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
71 TRACE("(%s,%lx)\n",lpFileName,attributes);
72 if (attributes & FILE_ATTRIBUTE_NORMAL) {
73 attributes &= ~FILE_ATTRIBUTE_NORMAL;
75 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
76 lpFileName,attributes);
78 if(stat(full_name.long_name,&buf)==-1)
80 SetLastError(ErrnoToLastError(errno));
83 if (attributes & FILE_ATTRIBUTE_READONLY)
85 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
86 attributes &= ~FILE_ATTRIBUTE_READONLY;
90 /* add write permission */
91 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
93 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
95 if (!S_ISDIR(buf.st_mode))
96 FIXME("SetFileAttributes expected the file '%s' to be a directory",
98 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
100 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
102 FIXME("(%s):%lx attribute(s) not implemented.\n",
103 lpFileName,attributes);
104 if (-1==chmod(full_name.long_name,buf.st_mode))
106 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
107 SetLastError(ErrnoToLastError(errno));
114 /**************************************************************************
115 * SetFileAttributes32W (KERNEL32.491)
117 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
119 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
120 BOOL res = SetFileAttributesA( afn, attributes );
121 HeapFree( GetProcessHeap(), 0, afn );
126 /**************************************************************************
127 * SetFileApisToOEM (KERNEL32.645)
129 VOID WINAPI SetFileApisToOEM(void)
131 /*FIXME(file,"(): stub!\n");*/
135 /**************************************************************************
136 * SetFileApisToANSI (KERNEL32.644)
138 VOID WINAPI SetFileApisToANSI(void)
140 /*FIXME(file,"(): stub\n");*/
144 /******************************************************************************
145 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
148 * TRUE: Set of file functions is using ANSI code page
149 * FALSE: Set of file functions is using OEM code page
151 BOOL WINAPI AreFileApisANSI(void)
153 FIXME("(void): stub\n");