Fixed some warnings.
[wine.git] / win32 / file.c
blob4d72eeb3c86b5b14dea8ccfe0e66dc7debe22092
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 "process.h"
27 #include "heap.h"
28 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(file);
32 /***********************************************************************
33 * ReadFileEx (KERNEL32.)
35 BOOL WINAPI ReadFileEx(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
36 LPOVERLAPPED lpOverlapped,
37 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
40 FIXME("file %d to buf %p num %ld %p func %p stub\n",
41 hFile, lpBuffer, numtoread, lpOverlapped, lpCompletionRoutine);
42 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
43 return 0;
46 /**************************************************************************
47 * SetFileAttributes16 (KERNEL.421)
49 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
51 return SetFileAttributesA( lpFileName, attributes );
55 /**************************************************************************
56 * SetFileAttributesA (KERNEL32.490)
58 BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD attributes)
60 struct stat buf;
61 DOS_FULL_NAME full_name;
63 if (!DOSFS_GetFullName( lpFileName, TRUE, &full_name ))
64 return FALSE;
66 TRACE("(%s,%lx)\n",lpFileName,attributes);
67 if (attributes & FILE_ATTRIBUTE_NORMAL) {
68 attributes &= ~FILE_ATTRIBUTE_NORMAL;
69 if (attributes)
70 FIXME("(%s):%lx illegal combination with FILE_ATTRIBUTE_NORMAL.\n",
71 lpFileName,attributes);
73 if(stat(full_name.long_name,&buf)==-1)
75 FILE_SetDosError();
76 return FALSE;
78 if (attributes & FILE_ATTRIBUTE_READONLY)
80 buf.st_mode &= ~0222; /* octal!, clear write permission bits */
81 attributes &= ~FILE_ATTRIBUTE_READONLY;
83 else
85 /* add write permission */
86 buf.st_mode |= 0600 | ((buf.st_mode & 044) >> 1);
88 if (attributes & FILE_ATTRIBUTE_DIRECTORY)
90 if (!S_ISDIR(buf.st_mode))
91 FIXME("SetFileAttributes expected the file '%s' to be a directory",
92 lpFileName);
93 attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
95 attributes &= ~(FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM);
96 if (attributes)
97 FIXME("(%s):%lx attribute(s) not implemented.\n",
98 lpFileName,attributes);
99 if (-1==chmod(full_name.long_name,buf.st_mode))
101 FILE_SetDosError();
102 MESSAGE("Wine ERROR: Couldn't set file attributes for existing file \"%s\". Check permissions !\n", full_name.long_name);
103 return FALSE;
105 return TRUE;
109 /**************************************************************************
110 * SetFileAttributesW (KERNEL32.491)
112 BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD attributes)
114 LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
115 BOOL res = SetFileAttributesA( afn, attributes );
116 HeapFree( GetProcessHeap(), 0, afn );
117 return res;
121 /**************************************************************************
122 * SetFileApisToOEM (KERNEL32.645)
124 VOID WINAPI SetFileApisToOEM(void)
126 /*FIXME(file,"(): stub!\n");*/
130 /**************************************************************************
131 * SetFileApisToANSI (KERNEL32.644)
133 VOID WINAPI SetFileApisToANSI(void)
135 /*FIXME(file,"(): stub\n");*/
139 /******************************************************************************
140 * AreFileApisANSI [KERNEL32.105] Determines if file functions are using ANSI
142 * RETURNS
143 * TRUE: Set of file functions is using ANSI code page
144 * FALSE: Set of file functions is using OEM code page
146 BOOL WINAPI AreFileApisANSI(void)
148 FIXME("(void): stub\n");
149 return TRUE;