Moved idle event handling to the server.
[wine.git] / win32 / file.c
blobcc735c4f235c439eac03aa272c1ad27c069714ef
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 BOOL WINAPI ReadFileEx(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
39 LPOVERLAPPED lpOverlapped,
40 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
43 FIXME("file %d to buf %p num %ld %p func %p stub\n",
44 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
45 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
46 return 0;
49 /**************************************************************************
50 * SetFileAttributes16 (KERNEL.421)
52 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
54 return SetFileAttributesA( lpFileName, attributes );
58 /**************************************************************************
59 * SetFileAttributesA (KERNEL32.490)
61 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
63 struct stat buf;
64 DOS_FULL_NAME full_name;
66 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
67 return FALSE;
69 TRACE("(%s,%lx)\n",lpFileName,attributes);
70 if (attributes & FILE_ATTRIBUTE_NORMAL) {
71 attributes &= ~FILE_ATTRIBUTE_NORMAL;
72 if (attributes)
73 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
74 lpFileName,attributes);
76 if(stat(full_name.long_name,&buf)==-1)
78 SetLastError(ErrnoToLastError(errno));
79 return FALSE;
81 if (attributes & FILE_ATTRIBUTE_READONLY)
83 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
84 attributes &= ~FILE_ATTRIBUTE_READONLY;
86 else
88 /* add write permission */
89 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
91 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
93 if (!S_ISDIR(buf.st_mode))
94 FIXME("SetFileAttributes expected the file '%s' to be a directory",
95 lpFileName);
96 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
98 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
99 if (attributes)
100 FIXME("(%s):%lx attribute(s) not implemented.\n",
101 lpFileName,attributes);
102 if (-1==chmod(full_name.long_name,buf.st_mode))
104 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
105 SetLastError(ErrnoToLastError(errno));
106 return FALSE;
108 return TRUE;
112 /**************************************************************************
113 * SetFileAttributesW (KERNEL32.491)
115 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
117 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
118 BOOL res = SetFileAttributesA( afn, attributes );
119 HeapFree( GetProcessHeap(), 0, afn );
120 return res;
124 /**************************************************************************
125 * SetFileApisToOEM (KERNEL32.645)
127 VOID WINAPI SetFileApisToOEM(void)
129 /*FIXME(file,"(): stub!\n");*/
133 /**************************************************************************
134 * SetFileApisToANSI (KERNEL32.644)
136 VOID WINAPI SetFileApisToANSI(void)
138 /*FIXME(file,"(): stub\n");*/
142 /******************************************************************************
143 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
145 * RETURNS
146 * TRUE: Set of file functions is using ANSI code page
147 * FALSE: Set of file functions is using OEM code page
149 BOOL WINAPI AreFileApisANSI(void)
151 FIXME("(void): stub\n");
152 return TRUE;