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 "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
)
47 DOS_FULL_NAME full_name
;
49 if (!DOSFS_GetFullName( lpFileName
, TRUE
, &full_name
))
52 TRACE("(%s,%lx)\n",lpFileName
,attributes
);
53 if (attributes
& FILE_ATTRIBUTE_NORMAL
) {
54 attributes
&= ~FILE_ATTRIBUTE_NORMAL
;
56 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
57 lpFileName
,attributes
);
59 if(stat(full_name
.long_name
,&buf
)==-1)
64 if (attributes
& FILE_ATTRIBUTE_READONLY
)
66 if(S_ISDIR(buf
.st_mode
))
68 WARN("FILE_ATTRIBUTE_READONLY ignored for directory.\n");
70 buf
.st_mode
&= ~0222; /* octal!, clear write permission bits */
71 attributes
&= ~FILE_ATTRIBUTE_READONLY
;
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",
83 attributes
&= ~FILE_ATTRIBUTE_DIRECTORY
;
85 attributes
&= ~(FILE_ATTRIBUTE_ARCHIVE
|FILE_ATTRIBUTE_HIDDEN
|FILE_ATTRIBUTE_SYSTEM
);
87 FIXME("(%s):%lx attribute(s) not implemented.\n",
88 lpFileName
,attributes
);
89 if (-1==chmod(full_name
.long_name
,buf
.st_mode
))
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
);
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
);