Release 990225.
[wine/multimedia.git] / win32 / file.c
blob7c484365b2908f026fb9204823e9e973ea3dfa42
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 DWORD ErrnoToLastError(int errno_num);
27 /***********************************************************************
28 * ReadFileEx (KERNEL32.)
30 typedef
31 VOID
32 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
33 DWORD dwErrorCode,
34 DWORD dwNumberOfBytesTransfered,
35 LPOVERLAPPED lpOverlapped
38 BOOL32 WINAPI ReadFileEx(HFILE32 hFile, LPVOID lpBuffer, DWORD numtoread,
39 LPOVERLAPPED lpOverlapped,
40 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
43 FIXME(file, "file %d to buf %p num %ld %p func %p stub\n",
44 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
45 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
46 return 0;
49 /**************************************************************************
50 * SetFileAttributes16 (KERNEL.421)
52 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
54 return SetFileAttributes32A( lpFileName, attributes );
58 /**************************************************************************
59 * SetFileAttributes32A (KERNEL32.490)
61 BOOL32 WINAPI SetFileAttributes32A(LPCSTR lpFileName, DWORD attributes)
63 struct stat buf;
64 DOS_FULL_NAME full_name;
66 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
67 return FALSE;
69 TRACE(file,"(%s,%lx)\n",lpFileName,attributes);
70 if (attributes & FILE_ATTRIBUTE_NORMAL) {
71 attributes &= ~FILE_ATTRIBUTE_NORMAL;
72 if (attributes)
73 FIXME(file,"(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
74 lpFileName,attributes);
76 if(stat(full_name.long_name,&buf)==-1)
78 SetLastError(ErrnoToLastError(errno));
79 return FALSE;
81 if (attributes & FILE_ATTRIBUTE_READONLY)
83 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
84 attributes &= ~FILE_ATTRIBUTE_READONLY;
86 else
88 /* add write permission */
89 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
91 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
92 if (attributes)
93 FIXME(file,"(%s):%lx attribute(s) not implemented.\n",
94 lpFileName,attributes);
95 if (-1==chmod(full_name.long_name,buf.st_mode))
97 MSG("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
98 SetLastError(ErrnoToLastError(errno));
99 return FALSE;
101 return TRUE;
105 /**************************************************************************
106 * SetFileAttributes32W (KERNEL32.491)
108 BOOL32 WINAPI SetFileAttributes32W(LPCWSTR lpFileName, DWORD attributes)
110 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
111 BOOL32 res = SetFileAttributes32A( afn, attributes );
112 HeapFree( GetProcessHeap(), 0, afn );
113 return res;
117 /**************************************************************************
118 * SetFileApisToOEM (KERNEL32.645)
120 VOID WINAPI SetFileApisToOEM(void)
122 /*FIXME(file,"(): stub!\n");*/
126 /**************************************************************************
127 * SetFileApisToANSI (KERNEL32.644)
129 VOID WINAPI SetFileApisToANSI(void)
131 /*FIXME(file,"(): stub\n");*/
135 /******************************************************************************
136 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
138 * RETURNS
139 * TRUE: Set of file functions is using ANSI code page
140 * FALSE: Set of file functions is using OEM code page
142 BOOL32 WINAPI AreFileApisANSI(void)
144 FIXME(file,"(void): stub\n");
145 return TRUE;