Implemented file sharing checks in the server.
[wine/multimedia.git] / win32 / file.c
blobb142513957eb059397b69ecef0c5fbd8ba466439
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 "windows.h"
18 #include "winbase.h"
19 #include "winerror.h"
20 #include "file.h"
21 #include "device.h"
22 #include "process.h"
23 #include "heap.h"
24 #include "debug.h"
26 DWORD ErrnoToLastError(int errno_num);
28 /***********************************************************************
29 * ReadFileEx (KERNEL32.)
31 typedef
32 VOID
33 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
34 DWORD dwErrorCode,
35 DWORD dwNumberOfBytesTransfered,
36 LPOVERLAPPED lpOverlapped
39 BOOL32 WINAPI ReadFileEx(HFILE32 hFile, LPVOID lpBuffer, DWORD numtoread,
40 LPOVERLAPPED lpOverlapped,
41 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
44 FIXME(file, "file %d to buf %p num %ld %p func %p stub\n",
45 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
46 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
47 return 0;
50 /**************************************************************************
51 * SetFileAttributes16 (KERNEL.421)
53 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
55 return SetFileAttributes32A( lpFileName, attributes );
59 /**************************************************************************
60 * SetFileAttributes32A (KERNEL32.490)
62 BOOL32 WINAPI SetFileAttributes32A(LPCSTR lpFileName, DWORD attributes)
64 struct stat buf;
65 DOS_FULL_NAME full_name;
67 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
68 return FALSE;
70 TRACE(file,"(%s,%lx)\n",lpFileName,attributes);
71 if (attributes & FILE_ATTRIBUTE_NORMAL) {
72 attributes &= ~FILE_ATTRIBUTE_NORMAL;
73 if (attributes)
74 FIXME(file,"(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
75 lpFileName,attributes);
77 if(stat(full_name.long_name,&buf)==-1)
79 SetLastError(ErrnoToLastError(errno));
80 return FALSE;
82 if (attributes & FILE_ATTRIBUTE_READONLY)
84 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
85 attributes &= ~FILE_ATTRIBUTE_READONLY;
87 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
88 if (attributes)
89 FIXME(file,"(%s):%lx attribute(s) not implemented.\n",
90 lpFileName,attributes);
91 if (-1==chmod(full_name.long_name,buf.st_mode))
93 SetLastError(ErrnoToLastError(errno));
94 return FALSE;
96 return TRUE;
100 /**************************************************************************
101 * SetFileAttributes32W (KERNEL32.491)
103 BOOL32 WINAPI SetFileAttributes32W(LPCWSTR lpFileName, DWORD attributes)
105 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
106 BOOL32 res = SetFileAttributes32A( afn, attributes );
107 HeapFree( GetProcessHeap(), 0, afn );
108 return res;
112 /**************************************************************************
113 * SetFileApisToOEM (KERNEL32.645)
115 VOID WINAPI SetFileApisToOEM(void)
117 /*FIXME(file,"(): stub!\n");*/
121 /**************************************************************************
122 * SetFileApisToANSI (KERNEL32.644)
124 VOID WINAPI SetFileApisToANSI(void)
126 /*FIXME(file,"(): stub\n");*/
130 /******************************************************************************
131 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
133 * RETURNS
134 * TRUE: Set of file functions is using ANSI code page
135 * FALSE: Set of file functions is using OEM code page
137 BOOL32 WINAPI AreFileApisANSI(void)
139 FIXME(file,"(void): stub\n");
140 return TRUE;