Fixed asm() constraints.
[wine/multimedia.git] / win32 / file.c
blob17cc9594e7456bec01fca6f390d3602343038810
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
5 */
7 #include "config.h"
9 #include <errno.h>
10 #ifdef HAVE_SYS_ERRNO_H
11 #include <sys/errno.h>
12 #endif
13 #include <stdlib.h>
14 #include <unistd.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #ifdef HAVE_SYS_MMAN_H
18 #include <sys/mman.h>
19 #endif
20 #include <fcntl.h>
21 #include <string.h>
22 #include <time.h>
23 #include "winbase.h"
24 #include "winerror.h"
25 #include "file.h"
26 #include "device.h"
27 #include "process.h"
28 #include "heap.h"
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(file)
33 DWORD ErrnoToLastError(int errno_num);
35 /***********************************************************************
36 * ReadFileEx (KERNEL32.)
38 typedef
39 VOID
40 (CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(
41 DWORD dwErrorCode,
42 DWORD dwNumberOfBytesTransfered,
43 LPOVERLAPPED lpOverlapped
46 BOOL WINAPI ReadFileEx(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
47 LPOVERLAPPED lpOverlapped,
48 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
51 FIXME("file %d to buf %p num %ld %p func %p stub\n",
52 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
53 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
54 return 0;
57 /**************************************************************************
58 * SetFileAttributes16 (KERNEL.421)
60 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
62 return SetFileAttributesA( lpFileName, attributes );
66 /**************************************************************************
67 * SetFileAttributesA (KERNEL32.490)
69 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
71 struct stat buf;
72 DOS_FULL_NAME full_name;
74 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
75 return FALSE;
77 TRACE("(%s,%lx)\n",lpFileName,attributes);
78 if (attributes & FILE_ATTRIBUTE_NORMAL) {
79 attributes &= ~FILE_ATTRIBUTE_NORMAL;
80 if (attributes)
81 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
82 lpFileName,attributes);
84 if(stat(full_name.long_name,&buf)==-1)
86 SetLastError(ErrnoToLastError(errno));
87 return FALSE;
89 if (attributes & FILE_ATTRIBUTE_READONLY)
91 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
92 attributes &= ~FILE_ATTRIBUTE_READONLY;
94 else
96 /* add write permission */
97 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
99 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
101 if (!S_ISDIR(buf.st_mode))
102 FIXME("SetFileAttributes expected the file '%s' to be a directory",
103 lpFileName);
104 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
106 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
107 if (attributes)
108 FIXME("(%s):%lx attribute(s) not implemented.\n",
109 lpFileName,attributes);
110 if (-1==chmod(full_name.long_name,buf.st_mode))
112 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
113 SetLastError(ErrnoToLastError(errno));
114 return FALSE;
116 return TRUE;
120 /**************************************************************************
121 * SetFileAttributesW (KERNEL32.491)
123 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
125 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
126 BOOL res = SetFileAttributesA( afn, attributes );
127 HeapFree( GetProcessHeap(), 0, afn );
128 return res;
132 /**************************************************************************
133 * SetFileApisToOEM (KERNEL32.645)
135 VOID WINAPI SetFileApisToOEM(void)
137 /*FIXME(file,"(): stub!\n");*/
141 /**************************************************************************
142 * SetFileApisToANSI (KERNEL32.644)
144 VOID WINAPI SetFileApisToANSI(void)
146 /*FIXME(file,"(): stub\n");*/
150 /******************************************************************************
151 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
153 * RETURNS
154 * TRUE: Set of file functions is using ANSI code page
155 * FALSE: Set of file functions is using OEM code page
157 BOOL WINAPI AreFileApisANSI(void)
159 FIXME("(void): stub\n");
160 return TRUE;