Added support for forwarded ordinals in built-in dlls.
[wine/multimedia.git] / win32 / file.c
blob93c757c3151ec18ef1aff0160c3981fbdd108d4b
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
5 */
7 #include <errno.h>
8 #include <sys/errno.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <sys/mman.h>
14 #include <fcntl.h>
15 #include <string.h>
16 #include <time.h>
17 #include "winbase.h"
18 #include "winerror.h"
19 #include "file.h"
20 #include "device.h"
21 #include "process.h"
22 #include "heap.h"
23 #include "debug.h"
25 DEFAULT_DEBUG_CHANNEL(file)
27 DWORD ErrnoToLastError(int errno_num);
29 /***********************************************************************
30 * ReadFileEx (KERNEL32.)
32 typedef
33 VOID
34 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
35 DWORD dwErrorCode,
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, "file %d to buf %p num %ld %p func %p stub\n",
46 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
47 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
48 return 0;
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)
65 struct stat buf;
66 DOS_FULL_NAME full_name;
68 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
69 return FALSE;
71 TRACE(file,"(%s,%lx)\n",lpFileName,attributes);
72 if (attributes & FILE_ATTRIBUTE_NORMAL) {
73 attributes &= ~FILE_ATTRIBUTE_NORMAL;
74 if (attributes)
75 FIXME(file,"(%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));
81 return FALSE;
83 if (attributes & FILE_ATTRIBUTE_READONLY)
85 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
86 attributes &= ~FILE_ATTRIBUTE_READONLY;
88 else
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(file,"SetFileAttributes expected the file '%s' to be a directory",
97 lpFileName);
98 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
100 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
101 if (attributes)
102 FIXME(file,"(%s):%lx attribute(s) not implemented.\n",
103 lpFileName,attributes);
104 if (-1==chmod(full_name.long_name,buf.st_mode))
106 MSG("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
107 SetLastError(ErrnoToLastError(errno));
108 return FALSE;
110 return TRUE;
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 );
122 return res;
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
147 * RETURNS
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(file,"(void): stub\n");
154 return TRUE;