2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis, Sven Verdoolaege, and Cameron Heide
11 #ifdef HAVE_SYS_ERRNO_H
12 #include <sys/errno.h>
16 #include <sys/types.h>
18 #ifdef HAVE_SYS_MMAN_H
28 #include "wine/winbase16.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)
51 DOS_FULL_NAME full_name;
53 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
56 TRACE("(%s,%lx)\n",lpFileName,attributes);
57 if (attributes & FILE_ATTRIBUTE_NORMAL) {
58 attributes &= ~FILE_ATTRIBUTE_NORMAL;
60 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
61 lpFileName,attributes);
63 if(stat(full_name.long_name,&buf)==-1)
68 if (attributes & FILE_ATTRIBUTE_READONLY)
70 if(S_ISDIR(buf.st_mode))
72 WARN("FILE_ATTRIBUTE_READONLY ignored for directory.\n");
74 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
75 attributes &= ~FILE_ATTRIBUTE_READONLY;
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",
87 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
89 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
91 FIXME("(%s):%lx attribute(s) not implemented.\n",
92 lpFileName,attributes);
93 if (-1==chmod(full_name.long_name,buf.st_mode))
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);
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 );