Added stubs for msdmo.dll, qcap.dll and devenum.dll.
[wine/multimedia.git] / win32 / file.c
blobc0a4591e00f3b534889c0432cc96c33fdacb4b69
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>
25 #include "winbase.h"
26 #include "winerror.h"
28 #include "wine/winbase16.h"
29 #include "file.h"
30 #include "heap.h"
32 #include "debugtools.h"
34 DEFAULT_DEBUG_CHANNEL(file);
36 /**************************************************************************
37 * SetFileAttributes (KERNEL.421)
39 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
41 return SetFileAttributesA( lpFileName, attributes );
45 /**************************************************************************
46 * SetFileAttributesA (KERNEL32.@)
48 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
50 struct stat buf;
51 DOS_FULL_NAME full_name;
53 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
54 return FALSE;
56 TRACE("(%s,%lx)\n",lpFileName,attributes);
57 if (attributes & FILE_ATTRIBUTE_NORMAL) {
58 attributes &= ~FILE_ATTRIBUTE_NORMAL;
59 if (attributes)
60 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
61 lpFileName,attributes);
63 if(stat(full_name.long_name,&buf)==-1)
65 FILE_SetDosError();
66 return FALSE;
68 if (attributes & FILE_ATTRIBUTE_READONLY)
70 if(S_ISDIR(buf.st_mode))
71 /* FIXME */
72 WARN("FILE_ATTRIBUTE_READONLY ignored for directory.\n");
73 else
74 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
75 attributes &= ~FILE_ATTRIBUTE_READONLY;
77 else
79 /* add write permission */
80 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
82 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
84 if (!S_ISDIR(buf.st_mode))
85 FIXME("SetFileAttributes expected the file '%s' to be a directory",
86 lpFileName);
87 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
89 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
90 if (attributes)
91 FIXME("(%s):%lx attribute(s) not implemented.\n",
92 lpFileName,attributes);
93 if (-1==chmod(full_name.long_name,buf.st_mode))
95 FILE_SetDosError();
96 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\".\n"
97 "Check permissions or set VFAT \"quiet\" mount flag\n", full_name.long_name);
98 return TRUE;
100 return TRUE;
104 /**************************************************************************
105 * SetFileAttributesW (KERNEL32.@)
107 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
109 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
110 BOOL res = SetFileAttributesA( afn, attributes );
111 HeapFree( GetProcessHeap(), 0, afn );
112 return res;