Declare stubs for ReadFileEx, WriteFileEx.
[wine/gsoc_dplay.git] / win32 / file.c
blob36eb56b5c02f7ff421fbffcd3f8dac561e3bc067
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
5 */
7 #include "config.h"
8 #include "wine/port.h"
10 #include <errno.h>
11 #ifdef HAVE_SYS_ERRNO_H
12 #include <sys/errno.h>
13 #endif
14 #include <stdlib.h>
15 #include <unistd.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #ifdef HAVE_SYS_MMAN_H
19 #include <sys/mman.h>
20 #endif
21 #include <fcntl.h>
22 #include <string.h>
23 #include <time.h>
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "file.h"
27 #include "heap.h"
28 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(file);
32 /**************************************************************************
33 * SetFileAttributes (KERNEL.421)
35 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
37 return SetFileAttributesA( lpFileName, attributes );
41 /**************************************************************************
42 * SetFileAttributesA (KERNEL32.@)
44 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
46 struct stat buf;
47 DOS_FULL_NAME full_name;
49 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
50 return FALSE;
52 TRACE("(%s,%lx)\n",lpFileName,attributes);
53 if (attributes & FILE_ATTRIBUTE_NORMAL) {
54 attributes &= ~FILE_ATTRIBUTE_NORMAL;
55 if (attributes)
56 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
57 lpFileName,attributes);
59 if(stat(full_name.long_name,&buf)==-1)
61 FILE_SetDosError();
62 return FALSE;
64 if (attributes & FILE_ATTRIBUTE_READONLY)
66 if(S_ISDIR(buf.st_mode))
67 /* FIXME */
68 WARN("FILE_ATTRIBUTE_READONLY ignored for directory.\n");
69 else
70 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
71 attributes &= ~FILE_ATTRIBUTE_READONLY;
73 else
75 /* add write permission */
76 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
78 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
80 if (!S_ISDIR(buf.st_mode))
81 FIXME("SetFileAttributes expected the file '%s' to be a directory",
82 lpFileName);
83 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
85 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
86 if (attributes)
87 FIXME("(%s):%lx attribute(s) not implemented.\n",
88 lpFileName,attributes);
89 if (-1==chmod(full_name.long_name,buf.st_mode))
91 FILE_SetDosError();
92 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\".\n"
93 "Check permissions or set VFAT \"quiet\" mount flag\n", full_name.long_name);
94 return TRUE;
96 return TRUE;
100 /**************************************************************************
101 * SetFileAttributesW (KERNEL32.@)
103 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
105 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
106 BOOL res = SetFileAttributesA( afn, attributes );
107 HeapFree( GetProcessHeap(), 0, afn );
108 return res;