Fixed RGBQUAD/COLORREF mixup in CreateMappedBitmap().
[wine.git] / win32 / file.c
blob67142bd46045a41b532c322aaff9128cab0c802b
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
5 */
7 #include <errno.h>
8 #ifdef HAVE_SYS_ERRNO_H
9 #include <sys/errno.h>
10 #endif
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <sys/types.h>
14 #include <sys/stat.h>
15 #ifdef HAVE_SYS_MMAN_H
16 #include <sys/mman.h>
17 #endif
18 #include <fcntl.h>
19 #include <string.h>
20 #include <time.h>
21 #include "winbase.h"
22 #include "winerror.h"
23 #include "file.h"
24 #include "device.h"
25 #include "process.h"
26 #include "heap.h"
27 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(file)
31 DWORD ErrnoToLastError(int errno_num);
33 /***********************************************************************
34 * ReadFileEx (KERNEL32.)
36 typedef
37 VOID
38 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
39 DWORD dwErrorCode,
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);
52 return 0;
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)
69 struct stat buf;
70 DOS_FULL_NAME full_name;
72 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
73 return FALSE;
75 TRACE("(%s,%lx)\n",lpFileName,attributes);
76 if (attributes & FILE_ATTRIBUTE_NORMAL) {
77 attributes &= ~FILE_ATTRIBUTE_NORMAL;
78 if (attributes)
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));
85 return FALSE;
87 if (attributes & FILE_ATTRIBUTE_READONLY)
89 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
90 attributes &= ~FILE_ATTRIBUTE_READONLY;
92 else
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",
101 lpFileName);
102 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
104 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
105 if (attributes)
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));
112 return FALSE;
114 return TRUE;
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 );
126 return res;
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
151 * RETURNS
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");
158 return TRUE;