Spelling fix.
[wine/wine-kai.git] / dlls / kernel / file16.c
blobd74a127157000f93561348fcf4d58941b5791122
1 /*
2 * File handling functions
4 * Copyright 1993 John Burton
5 * Copyright 1996 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * TODO:
22 * Fix the CopyFileEx methods to implement the "extended" functionality.
23 * Right now, they simply call the CopyFile method.
26 #include "config.h"
27 #include "wine/port.h"
29 #include <stdio.h>
30 #include <assert.h>
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
34 #include "winerror.h"
35 #include "windef.h"
36 #include "winbase.h"
37 #include "winternl.h"
38 #include "wine/winbase16.h"
39 #include "wine/server.h"
41 #include "msdos.h"
42 #include "kernel_private.h"
44 #include "wine/unicode.h"
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(file);
49 /***********************************************************************
50 * _hread16 (KERNEL.349)
52 LONG WINAPI _hread16( HFILE16 hFile, LPVOID buffer, LONG count)
54 return _lread( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, count );
58 /***********************************************************************
59 * _hwrite (KERNEL.350)
61 LONG WINAPI _hwrite16( HFILE16 hFile, LPCSTR buffer, LONG count )
63 return _hwrite( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, count );
67 /***********************************************************************
68 * _lcreat (KERNEL.83)
70 HFILE16 WINAPI _lcreat16( LPCSTR path, INT16 attr )
72 return Win32HandleToDosFileHandle( (HANDLE)_lcreat( path, attr ) );
75 /***********************************************************************
76 * _llseek (KERNEL.84)
78 * FIXME:
79 * Seeking before the start of the file should be allowed for _llseek16,
80 * but cause subsequent I/O operations to fail (cf. interrupt list)
83 LONG WINAPI _llseek16( HFILE16 hFile, LONG lOffset, INT16 nOrigin )
85 return SetFilePointer( DosFileHandleToWin32Handle(hFile), lOffset, NULL, nOrigin );
89 /***********************************************************************
90 * _lopen (KERNEL.85)
92 HFILE16 WINAPI _lopen16( LPCSTR path, INT16 mode )
94 return Win32HandleToDosFileHandle( (HANDLE)_lopen( path, mode ) );
98 /***********************************************************************
99 * _lread16 (KERNEL.82)
101 UINT16 WINAPI _lread16( HFILE16 hFile, LPVOID buffer, UINT16 count )
103 return (UINT16)_lread((HFILE)DosFileHandleToWin32Handle(hFile), buffer, (LONG)count );
107 /***********************************************************************
108 * _lwrite (KERNEL.86)
110 UINT16 WINAPI _lwrite16( HFILE16 hFile, LPCSTR buffer, UINT16 count )
112 return (UINT16)_hwrite( (HFILE)DosFileHandleToWin32Handle(hFile), buffer, (LONG)count );
115 /***********************************************************************
116 * _hread (KERNEL.349)
118 LONG WINAPI WIN16_hread( HFILE16 hFile, SEGPTR buffer, LONG count )
120 LONG maxlen;
122 TRACE("%d %08lx %ld\n", hFile, (DWORD)buffer, count );
124 /* Some programs pass a count larger than the allocated buffer */
125 maxlen = GetSelectorLimit16( SELECTOROF(buffer) ) - OFFSETOF(buffer) + 1;
126 if (count > maxlen) count = maxlen;
127 return _lread((HFILE)DosFileHandleToWin32Handle(hFile), MapSL(buffer), count );
131 /***********************************************************************
132 * _lread (KERNEL.82)
134 UINT16 WINAPI WIN16_lread( HFILE16 hFile, SEGPTR buffer, UINT16 count )
136 return (UINT16)WIN16_hread( hFile, buffer, (LONG)count );
140 /***********************************************************************
141 * DeleteFile (KERNEL.146)
143 BOOL16 WINAPI DeleteFile16( LPCSTR path )
145 return DeleteFileA( path );
148 /**************************************************************************
149 * GetFileAttributes (KERNEL.420)
151 DWORD WINAPI GetFileAttributes16( LPCSTR name )
153 return GetFileAttributesA( name );
157 /***********************************************************************
158 * GetTempFileName (KERNEL.97)
160 UINT16 WINAPI GetTempFileName16( BYTE drive, LPCSTR prefix, UINT16 unique,
161 LPSTR buffer )
163 char temppath[MAX_PATH];
164 char *prefix16 = NULL;
165 UINT16 ret;
167 if (!(drive & ~TF_FORCEDRIVE)) /* drive 0 means current default drive */
169 GetCurrentDirectoryA(sizeof(temppath), temppath);
170 drive |= temppath[0];
173 if (drive & TF_FORCEDRIVE)
175 char d[3];
177 d[0] = drive & ~TF_FORCEDRIVE;
178 d[1] = ':';
179 d[2] = '\0';
180 if (GetDriveTypeA(d) == DRIVE_NO_ROOT_DIR)
182 drive &= ~TF_FORCEDRIVE;
183 WARN("invalid drive %d specified\n", drive );
187 if (drive & TF_FORCEDRIVE)
188 sprintf(temppath,"%c:", drive & ~TF_FORCEDRIVE );
189 else
190 GetTempPathA( MAX_PATH, temppath );
192 if (prefix)
194 prefix16 = HeapAlloc(GetProcessHeap(), 0, strlen(prefix) + 2);
195 *prefix16 = '~';
196 strcpy(prefix16 + 1, prefix);
199 ret = GetTempFileNameA( temppath, prefix16, unique, buffer );
201 if (prefix16) HeapFree(GetProcessHeap(), 0, prefix16);
202 return ret;
205 /**************************************************************************
206 * SetFileAttributes (KERNEL.421)
208 BOOL16 WINAPI SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
210 return SetFileAttributesA( lpFileName, attributes );
214 /***********************************************************************
215 * SetHandleCount (KERNEL.199)
217 UINT16 WINAPI SetHandleCount16( UINT16 count )
219 return SetHandleCount( count );