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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Fix the CopyFileEx methods to implement the "extended" functionality.
23 * Right now, they simply call the CopyFile method.
35 #include "wine/winbase16.h"
36 #include "kernel16_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(file
);
41 #define DOS_TABLE_SIZE 256
43 static HANDLE dos_handles
[DOS_TABLE_SIZE
];
45 /***********************************************************************
46 * FILE_InitProcessDosHandles
48 * Allocates the default DOS handles for a process. Called either by
49 * Win32HandleToDosFileHandle below or by the DOSVM stuff.
51 static void FILE_InitProcessDosHandles( void )
53 HANDLE hStdInput
, hStdOutput
, hStdError
, hNull
;
54 static BOOL init_done
/* = FALSE */;
55 HANDLE cp
= GetCurrentProcess();
57 if (init_done
) return;
59 hStdInput
= GetStdHandle(STD_INPUT_HANDLE
);
60 hStdOutput
= GetStdHandle(STD_OUTPUT_HANDLE
);
61 hStdError
= GetStdHandle(STD_ERROR_HANDLE
);
62 hNull
= CreateFileA("NUL", GENERIC_READ
|GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, 0);
63 /* Invalid console handles need to translate to real DOS handles in a new process */
64 if (!hStdInput
) hStdInput
= hNull
;
65 if (!hStdOutput
) hStdOutput
= hNull
;
66 if (!hStdError
) hStdError
= hNull
;
67 DuplicateHandle(cp
, hStdInput
, cp
, &dos_handles
[0], 0, TRUE
, DUPLICATE_SAME_ACCESS
);
68 DuplicateHandle(cp
, hStdOutput
, cp
, &dos_handles
[1], 0, TRUE
, DUPLICATE_SAME_ACCESS
);
69 DuplicateHandle(cp
, hStdError
, cp
, &dos_handles
[2], 0, TRUE
, DUPLICATE_SAME_ACCESS
);
70 DuplicateHandle(cp
, hStdError
, cp
, &dos_handles
[3], 0, TRUE
, DUPLICATE_SAME_ACCESS
);
71 DuplicateHandle(cp
, hStdError
, cp
, &dos_handles
[4], 0, TRUE
, DUPLICATE_SAME_ACCESS
);
75 /***********************************************************************
76 * DosFileHandleToWin32Handle (KERNEL32.20)
78 * Return the Win32 handle for a DOS handle.
80 * Note: this is not exactly right, since on Win95 the Win32 handles
81 * are on top of DOS handles and we do it the other way
82 * around. Should be good enough though.
84 HANDLE WINAPI
DosFileHandleToWin32Handle( HFILE handle
)
86 HFILE16 hfile
= (HFILE16
)handle
;
87 if (hfile
< 5) FILE_InitProcessDosHandles();
88 if ((hfile
>= DOS_TABLE_SIZE
) || !dos_handles
[hfile
])
90 SetLastError( ERROR_INVALID_HANDLE
);
91 return INVALID_HANDLE_VALUE
;
93 return dos_handles
[hfile
];
96 /***********************************************************************
97 * Win32HandleToDosFileHandle (KERNEL32.21)
99 * Allocate a DOS handle for a Win32 handle. The Win32 handle is no
100 * longer valid after this function (even on failure).
102 * Note: this is not exactly right, since on Win95 the Win32 handles
103 * are on top of DOS handles and we do it the other way
104 * around. Should be good enough though.
106 HFILE WINAPI
Win32HandleToDosFileHandle( HANDLE handle
)
110 if (!handle
|| (handle
== INVALID_HANDLE_VALUE
))
113 for (i
= 5; i
< DOS_TABLE_SIZE
; i
++)
116 dos_handles
[i
] = handle
;
117 TRACE("Got %d for h32 %p\n", i
, handle
);
120 CloseHandle( handle
);
121 SetLastError( ERROR_TOO_MANY_OPEN_FILES
);
125 /***********************************************************************
126 * DisposeLZ32Handle (KERNEL32.22)
128 * Note: this is not entirely correct, we should only close the
129 * 32-bit handle and not the 16-bit one, but we cannot do
130 * this because of the way our DOS handles are implemented.
131 * It shouldn't break anything though.
133 void WINAPI
DisposeLZ32Handle( HANDLE handle
)
137 if (!handle
|| (handle
== INVALID_HANDLE_VALUE
)) return;
139 for (i
= 5; i
< DOS_TABLE_SIZE
; i
++)
140 if (dos_handles
[i
] == handle
)
143 CloseHandle( handle
);
148 /***********************************************************************
149 * GetProfileInt (KERNEL.57)
151 UINT16 WINAPI
GetProfileInt16( LPCSTR section
, LPCSTR entry
, INT16 def_val
)
153 return GetPrivateProfileInt16( section
, entry
, def_val
, "win.ini" );
157 /***********************************************************************
158 * GetProfileString (KERNEL.58)
160 INT16 WINAPI
GetProfileString16( LPCSTR section
, LPCSTR entry
, LPCSTR def_val
,
161 LPSTR buffer
, UINT16 len
)
163 return GetPrivateProfileString16( section
, entry
, def_val
,
164 buffer
, len
, "win.ini" );
168 /***********************************************************************
169 * WriteProfileString (KERNEL.59)
171 BOOL16 WINAPI
WriteProfileString16( LPCSTR section
, LPCSTR entry
,
174 return WritePrivateProfileString16( section
, entry
, string
, "win.ini" );
178 /* get the search path for the current module; helper for OpenFile16 */
179 static char *get_search_path(void)
182 char *ret
, *p
, module
[OFS_MAXPATHNAME
];
185 if (GetCurrentTask() && GetModuleFileName16( GetCurrentTask(), module
, sizeof(module
) ))
187 if (!(p
= strrchr( module
, '\\' ))) p
= module
;
191 len
= (2 + /* search order: first current dir */
192 GetSystemDirectory16( NULL
, 0 ) + 1 + /* then system dir */
193 GetWindowsDirectoryA( NULL
, 0 ) + 1 + /* then windows dir */
194 strlen( module
) + 1 + /* then module path */
195 GetEnvironmentVariableA( "PATH", NULL
, 0 ) + 1); /* then look in PATH */
196 if (!(ret
= HeapAlloc( GetProcessHeap(), 0, len
))) return NULL
;
199 GetSystemDirectory16( p
, ret
+ len
- p
);
202 GetWindowsDirectoryA( p
, ret
+ len
- p
);
211 GetEnvironmentVariableA( "PATH", p
, ret
+ len
- p
);
215 /***********************************************************************
216 * OpenFile (KERNEL.74)
217 * OpenFileEx (KERNEL.360)
219 HFILE16 WINAPI
OpenFile16( LPCSTR name
, OFSTRUCT
*ofs
, UINT16 mode
)
224 WORD filedatetime
[2];
225 const char *p
, *filename
;
227 if (!ofs
) return HFILE_ERROR
;
229 TRACE("%s %s %s %s%s%s%s%s%s%s%s%s\n",debugstr_a(name
),
230 ((mode
& 0x3 )==OF_READ
)?"OF_READ":
231 ((mode
& 0x3 )==OF_WRITE
)?"OF_WRITE":
232 ((mode
& 0x3 )==OF_READWRITE
)?"OF_READWRITE":"unknown",
233 ((mode
& 0x70 )==OF_SHARE_COMPAT
)?"OF_SHARE_COMPAT":
234 ((mode
& 0x70 )==OF_SHARE_DENY_NONE
)?"OF_SHARE_DENY_NONE":
235 ((mode
& 0x70 )==OF_SHARE_DENY_READ
)?"OF_SHARE_DENY_READ":
236 ((mode
& 0x70 )==OF_SHARE_DENY_WRITE
)?"OF_SHARE_DENY_WRITE":
237 ((mode
& 0x70 )==OF_SHARE_EXCLUSIVE
)?"OF_SHARE_EXCLUSIVE":"unknown",
238 ((mode
& OF_PARSE
)==OF_PARSE
)?"OF_PARSE ":"",
239 ((mode
& OF_DELETE
)==OF_DELETE
)?"OF_DELETE ":"",
240 ((mode
& OF_VERIFY
)==OF_VERIFY
)?"OF_VERIFY ":"",
241 ((mode
& OF_SEARCH
)==OF_SEARCH
)?"OF_SEARCH ":"",
242 ((mode
& OF_CANCEL
)==OF_CANCEL
)?"OF_CANCEL ":"",
243 ((mode
& OF_CREATE
)==OF_CREATE
)?"OF_CREATE ":"",
244 ((mode
& OF_PROMPT
)==OF_PROMPT
)?"OF_PROMPT ":"",
245 ((mode
& OF_EXIST
)==OF_EXIST
)?"OF_EXIST ":"",
246 ((mode
& OF_REOPEN
)==OF_REOPEN
)?"OF_REOPEN ":""
251 OpenFile( name
, ofs
, mode
);
255 if (mode
& OF_CREATE
)
257 handle
= (HANDLE
)OpenFile( name
, ofs
, mode
);
258 if (handle
== (HANDLE
)HFILE_ERROR
) goto error
;
262 ofs
->cBytes
= sizeof(OFSTRUCT
);
264 if (mode
& OF_REOPEN
) name
= ofs
->szPathName
;
266 if (!name
) return HFILE_ERROR
;
268 /* the watcom 10.6 IDE relies on a valid path returned in ofs->szPathName
269 Are there any cases where getting the path here is wrong?
270 Uwe Bonnes 1997 Apr 2 */
271 if (!GetFullPathNameA( name
, sizeof(ofs
->szPathName
), ofs
->szPathName
, NULL
)) goto error
;
273 /* If OF_SEARCH is set, ignore the given path */
276 if ((mode
& OF_SEARCH
) && !(mode
& OF_REOPEN
))
278 /* First try the file name as is */
279 if (GetFileAttributesA( filename
) != INVALID_FILE_ATTRIBUTES
) filename
= NULL
;
282 /* Now remove the path */
283 if (filename
[0] && (filename
[1] == ':')) filename
+= 2;
284 if ((p
= strrchr( filename
, '\\' ))) filename
= p
+ 1;
285 if ((p
= strrchr( filename
, '/' ))) filename
= p
+ 1;
288 SetLastError( ERROR_FILE_NOT_FOUND
);
294 /* Now look for the file */
299 char *path
= get_search_path();
301 if (!path
) goto error
;
302 found
= SearchPathA( path
, filename
, NULL
, sizeof(ofs
->szPathName
),
303 ofs
->szPathName
, NULL
);
304 HeapFree( GetProcessHeap(), 0, path
);
305 if (!found
) goto error
;
308 TRACE("found %s\n", debugstr_a(ofs
->szPathName
) );
310 if (mode
& OF_DELETE
)
312 if (!DeleteFileA( ofs
->szPathName
)) goto error
;
313 TRACE("(%s): OF_DELETE return = OK\n", name
);
317 handle
= (HANDLE
)_lopen( ofs
->szPathName
, mode
);
318 if (handle
== INVALID_HANDLE_VALUE
) goto error
;
320 GetFileTime( handle
, NULL
, NULL
, &filetime
);
321 FileTimeToDosDateTime( &filetime
, &filedatetime
[0], &filedatetime
[1] );
322 if ((mode
& OF_VERIFY
) && (mode
& OF_REOPEN
))
324 if (ofs
->Reserved1
!= filedatetime
[0] || ofs
->Reserved2
!= filedatetime
[1] )
326 CloseHandle( handle
);
327 WARN("(%s): OF_VERIFY failed\n", name
);
328 /* FIXME: what error here? */
329 SetLastError( ERROR_FILE_NOT_FOUND
);
333 ofs
->Reserved1
= filedatetime
[0];
334 ofs
->Reserved2
= filedatetime
[1];
337 TRACE("(%s): OK, return = %p\n", name
, handle
);
338 hFileRet
= Win32HandleToDosFileHandle( handle
);
339 if (hFileRet
== HFILE_ERROR16
) goto error
;
340 if (mode
& OF_EXIST
) _lclose16( hFileRet
); /* Return the handle, but close it first */
343 error
: /* We get here if there was an error opening the file */
344 ofs
->nErrCode
= GetLastError();
345 WARN("(%s): return = HFILE_ERROR error= %d\n", name
,ofs
->nErrCode
);
346 return HFILE_ERROR16
;
350 /***********************************************************************
351 * _lclose (KERNEL.81)
353 HFILE16 WINAPI
_lclose16( HFILE16 hFile
)
355 if ((hFile
>= DOS_TABLE_SIZE
) || !dos_handles
[hFile
])
357 SetLastError( ERROR_INVALID_HANDLE
);
358 return HFILE_ERROR16
;
360 TRACE("%d (handle32=%p)\n", hFile
, dos_handles
[hFile
] );
361 CloseHandle( dos_handles
[hFile
] );
362 dos_handles
[hFile
] = 0;
366 /***********************************************************************
367 * _lcreat (KERNEL.83)
369 HFILE16 WINAPI
_lcreat16( LPCSTR path
, INT16 attr
)
371 return Win32HandleToDosFileHandle( (HANDLE
)_lcreat( path
, attr
) );
374 /***********************************************************************
375 * _llseek (KERNEL.84)
378 * Seeking before the start of the file should be allowed for _llseek16,
379 * but cause subsequent I/O operations to fail (cf. interrupt list)
382 LONG WINAPI
_llseek16( HFILE16 hFile
, LONG lOffset
, INT16 nOrigin
)
384 return SetFilePointer( DosFileHandleToWin32Handle(hFile
), lOffset
, NULL
, nOrigin
);
388 /***********************************************************************
391 HFILE16 WINAPI
_lopen16( LPCSTR path
, INT16 mode
)
393 return Win32HandleToDosFileHandle( (HANDLE
)_lopen( path
, mode
) );
397 /***********************************************************************
398 * _lread16 (internal)
400 UINT16 WINAPI
_lread16( HFILE16 hFile
, LPVOID buffer
, UINT16 count
)
402 return (UINT16
)_lread((HFILE
)DosFileHandleToWin32Handle(hFile
), buffer
, (LONG
)count
);
406 /***********************************************************************
407 * _lwrite (KERNEL.86)
409 UINT16 WINAPI
_lwrite16( HFILE16 hFile
, LPCSTR buffer
, UINT16 count
)
411 return (UINT16
)_hwrite( (HFILE
)DosFileHandleToWin32Handle(hFile
), buffer
, (LONG
)count
);
414 /***********************************************************************
415 * _hread (KERNEL.349)
417 LONG WINAPI
WIN16_hread( HFILE16 hFile
, SEGPTR buffer
, LONG count
)
421 TRACE("%d %08lx %ld\n", hFile
, (DWORD
)buffer
, count
);
423 /* Some programs pass a count larger than the allocated buffer */
424 maxlen
= GetSelectorLimit16( SELECTOROF(buffer
) ) - OFFSETOF(buffer
) + 1;
425 if (count
> maxlen
) count
= maxlen
;
426 return _lread((HFILE
)DosFileHandleToWin32Handle(hFile
), MapSL(buffer
), count
);
430 /***********************************************************************
433 UINT16 WINAPI
WIN16_lread( HFILE16 hFile
, SEGPTR buffer
, UINT16 count
)
435 return (UINT16
)WIN16_hread( hFile
, buffer
, (LONG
)count
);
439 /***********************************************************************
440 * _hwrite (KERNEL.350)
442 LONG WINAPI
_hwrite16( HFILE16 hFile
, LPCSTR buffer
, LONG count
)
444 return _hwrite( (HFILE
)DosFileHandleToWin32Handle(hFile
), buffer
, count
);
448 /***********************************************************************
449 * GetTempDrive (KERNEL.92)
450 * A closer look at krnl386.exe shows what the SDK doesn't mention:
454 * AH: ':' - yes, some kernel code even does stosw with
458 UINT WINAPI
GetTempDrive( BYTE ignored
)
460 WCHAR buffer
[MAX_PATH
];
463 if (GetTempPathW( MAX_PATH
, buffer
))
466 if (ret
>= 'a' && ret
<= 'z') ret
+= 'A' - 'a';
468 return MAKELONG( ret
| (':' << 8), 1 );
472 /***********************************************************************
473 * GetTempFileName (KERNEL.97)
475 UINT16 WINAPI
GetTempFileName16( BYTE drive
, LPCSTR prefix
, UINT16 unique
,
478 char temppath
[MAX_PATH
];
479 char *prefix16
= NULL
;
482 if (!(drive
& ~TF_FORCEDRIVE
)) /* drive 0 means current default drive */
484 GetCurrentDirectoryA(sizeof(temppath
), temppath
);
485 drive
|= temppath
[0];
488 if (drive
& TF_FORCEDRIVE
)
492 d
[0] = drive
& ~TF_FORCEDRIVE
;
495 if (GetDriveTypeA(d
) == DRIVE_NO_ROOT_DIR
)
497 drive
&= ~TF_FORCEDRIVE
;
498 WARN("invalid drive %d specified\n", drive
);
502 if (drive
& TF_FORCEDRIVE
)
503 sprintf(temppath
,"%c:", drive
& ~TF_FORCEDRIVE
);
505 GetTempPathA( MAX_PATH
, temppath
);
509 prefix16
= HeapAlloc(GetProcessHeap(), 0, strlen(prefix
) + 2);
511 strcpy(prefix16
+ 1, prefix
);
514 ret
= GetTempFileNameA( temppath
, prefix16
, unique
, buffer
);
516 HeapFree(GetProcessHeap(), 0, prefix16
);
521 /***********************************************************************
522 * GetPrivateProfileInt (KERNEL.127)
524 UINT16 WINAPI
GetPrivateProfileInt16( LPCSTR section
, LPCSTR entry
,
525 INT16 def_val
, LPCSTR filename
)
527 /* we used to have some elaborate return value limitation (<= -32768 etc.)
528 * here, but Win98SE doesn't care about this at all, so I deleted it.
529 * AFAIR versions prior to Win9x had these limits, though. */
530 return (INT16
)GetPrivateProfileIntA(section
,entry
,def_val
,filename
);
534 /***********************************************************************
535 * GetPrivateProfileString (KERNEL.128)
537 INT16 WINAPI
GetPrivateProfileString16( LPCSTR section
, LPCSTR entry
,
538 LPCSTR def_val
, LPSTR buffer
,
539 UINT16 len
, LPCSTR filename
)
541 TRACE("(%s, %s, %s, %p, %u, %s)\n", debugstr_a(section
), debugstr_a(entry
),
542 debugstr_a(def_val
), buffer
, len
, debugstr_a(filename
));
546 if (buffer
&& len
) buffer
[0] = 0;
551 /* We have to return the list of keys in the section but without the values
552 * so we need to massage the results of GetPrivateProfileSectionA.
554 UINT ret
, oldlen
= len
, size
= min( len
, 1024 );
559 if (!(data
= HeapAlloc(GetProcessHeap(), 0, size
))) return 0;
560 ret
= GetPrivateProfileSectionA( section
, data
, size
, filename
);
563 HeapFree( GetProcessHeap(), 0, data
);
564 return GetPrivateProfileStringA( section
, entry
, def_val
, buffer
, len
, filename
);
566 if (ret
!= size
- 2) break;
567 /* overflow, try again */
569 HeapFree( GetProcessHeap(), 0, data
);
575 char *p
= strchr( src
, '=' );
577 /* A valid entry is formed by name = value */
580 src
+= strlen(src
) + 1;
585 memcpy( buffer
, src
, p
- src
);
588 len
-= (p
- src
) + 1;
589 src
+= strlen(src
) + 1;
593 memcpy( buffer
, src
, len
);
598 HeapFree( GetProcessHeap(), 0, data
);
613 return GetPrivateProfileStringA( section
, entry
, def_val
, buffer
, len
, filename
);
617 /***********************************************************************
618 * WritePrivateProfileString (KERNEL.129)
620 BOOL16 WINAPI
WritePrivateProfileString16( LPCSTR section
, LPCSTR entry
,
621 LPCSTR string
, LPCSTR filename
)
623 return WritePrivateProfileStringA(section
,entry
,string
,filename
);
627 /***********************************************************************
628 * GetWindowsDirectory (KERNEL.134)
630 UINT16 WINAPI
GetWindowsDirectory16( LPSTR path
, UINT16 count
)
632 return GetWindowsDirectoryA( path
, count
);
636 /***********************************************************************
637 * GetSystemDirectory (KERNEL.135)
639 UINT16 WINAPI
GetSystemDirectory16( LPSTR path
, UINT16 count
)
641 static const char system16
[] = "\\SYSTEM";
642 char windir
[MAX_PATH
];
645 len
= GetWindowsDirectory16(windir
, sizeof(windir
) - sizeof(system16
) + 1) + sizeof(system16
);
648 lstrcpyA(path
, windir
);
649 lstrcatA(path
, system16
);
650 len
--; /* space for the terminating zero is not included on success */
656 /***********************************************************************
657 * GetDriveType (KERNEL.136)
658 * Get the type of a drive in Win16.
661 * The type of the Drive. For a list see GetDriveTypeW from kernel32.
664 * Note that it returns DRIVE_REMOTE for CD-ROMs, since MSCDEX uses the
665 * remote drive API. The return value DRIVE_REMOTE for CD-ROMs has been
666 * verified on Win 3.11 and Windows 95. Some programs rely on it, so don't
667 * do any pseudo-clever changes.
669 UINT16 WINAPI
GetDriveType16( UINT16 drive
) /* [in] number (NOT letter) of drive */
674 root
[0] = 'A' + drive
;
677 type
= GetDriveTypeW( root
);
678 if (type
== DRIVE_CDROM
) type
= DRIVE_REMOTE
;
679 else if (type
== DRIVE_NO_ROOT_DIR
) type
= DRIVE_UNKNOWN
;
684 /***********************************************************************
685 * GetProfileSectionNames (KERNEL.142)
687 WORD WINAPI
GetProfileSectionNames16(LPSTR buffer
, WORD size
)
690 return GetPrivateProfileSectionNamesA(buffer
,size
,"win.ini");
694 /***********************************************************************
695 * GetPrivateProfileSectionNames (KERNEL.143)
697 WORD WINAPI
GetPrivateProfileSectionNames16( LPSTR buffer
, WORD size
,
700 return GetPrivateProfileSectionNamesA(buffer
,size
,filename
);
704 /***********************************************************************
705 * CreateDirectory (KERNEL.144)
707 BOOL16 WINAPI
CreateDirectory16( LPCSTR path
, LPVOID dummy
)
709 return CreateDirectoryA( path
, NULL
);
713 /***********************************************************************
714 * RemoveDirectory (KERNEL.145)
716 BOOL16 WINAPI
RemoveDirectory16( LPCSTR path
)
718 return RemoveDirectoryA( path
);
722 /***********************************************************************
723 * DeleteFile (KERNEL.146)
725 BOOL16 WINAPI
DeleteFile16( LPCSTR path
)
727 return DeleteFileA( path
);
731 /***********************************************************************
732 * SetHandleCount (KERNEL.199)
734 UINT16 WINAPI
SetHandleCount16( UINT16 count
)
736 return SetHandleCount( count
);
740 /***********************************************************************
741 * GetShortPathName (KERNEL.274)
743 WORD WINAPI
GetShortPathName16( LPCSTR longpath
, LPSTR shortpath
, WORD len
)
745 return GetShortPathNameA( longpath
, shortpath
, len
);
749 /***********************************************************************
750 * WriteOutProfiles (KERNEL.315)
752 void WINAPI
WriteOutProfiles16(void)
754 WritePrivateProfileSectionW( NULL
, NULL
, NULL
);
758 /***********************************************************************
759 * WritePrivateProfileStruct (KERNEL.406)
761 BOOL16 WINAPI
WritePrivateProfileStruct16 (LPCSTR section
, LPCSTR key
,
762 LPVOID buf
, UINT16 bufsize
, LPCSTR filename
)
764 return WritePrivateProfileStructA( section
, key
, buf
, bufsize
, filename
);
768 /***********************************************************************
769 * GetPrivateProfileStruct (KERNEL.407)
771 BOOL16 WINAPI
GetPrivateProfileStruct16(LPCSTR section
, LPCSTR key
,
772 LPVOID buf
, UINT16 len
, LPCSTR filename
)
774 return GetPrivateProfileStructA( section
, key
, buf
, len
, filename
);
778 /***********************************************************************
779 * GetCurrentDirectory (KERNEL.411)
781 UINT16 WINAPI
GetCurrentDirectory16( UINT16 buflen
, LPSTR buf
)
783 return GetCurrentDirectoryA( buflen
, buf
);
787 /***********************************************************************
788 * SetCurrentDirectory (KERNEL.412)
790 BOOL16 WINAPI
SetCurrentDirectory16( LPCSTR dir
)
792 char fulldir
[MAX_PATH
];
794 if (!GetFullPathNameA( dir
, MAX_PATH
, fulldir
, NULL
)) return FALSE
;
796 if (!SetCurrentDirectoryA( dir
)) return FALSE
;
798 if (fulldir
[0] && fulldir
[1] == ':')
800 TDB
*pTask
= GlobalLock16( GetCurrentTask() );
801 char env_var
[4] = "=A:";
803 env_var
[1] = fulldir
[0];
804 SetEnvironmentVariableA( env_var
, fulldir
);
806 /* update the directory in the TDB */
809 pTask
->curdrive
= 0x80 | (fulldir
[0] - 'A');
810 GetShortPathNameA( fulldir
+ 2, pTask
->curdir
, sizeof(pTask
->curdir
) );
817 /*************************************************************************
818 * FindFirstFile (KERNEL.413)
820 HANDLE16 WINAPI
FindFirstFile16( LPCSTR path
, WIN32_FIND_DATAA
*data
)
825 if (!(h16
= GlobalAlloc16( GMEM_MOVEABLE
, sizeof(handle
) ))) return INVALID_HANDLE_VALUE16
;
826 ptr
= GlobalLock16( h16
);
827 *ptr
= handle
= FindFirstFileA( path
, data
);
828 GlobalUnlock16( h16
);
830 if (handle
== INVALID_HANDLE_VALUE
)
833 h16
= INVALID_HANDLE_VALUE16
;
839 /*************************************************************************
840 * FindNextFile (KERNEL.414)
842 BOOL16 WINAPI
FindNextFile16( HANDLE16 handle
, WIN32_FIND_DATAA
*data
)
847 if ((handle
== INVALID_HANDLE_VALUE16
) || !(ptr
= GlobalLock16( handle
)))
849 SetLastError( ERROR_INVALID_HANDLE
);
852 ret
= FindNextFileA( *ptr
, data
);
853 GlobalUnlock16( handle
);
858 /*************************************************************************
859 * FindClose (KERNEL.415)
861 BOOL16 WINAPI
FindClose16( HANDLE16 handle
)
865 if ((handle
== INVALID_HANDLE_VALUE16
) || !(ptr
= GlobalLock16( handle
)))
867 SetLastError( ERROR_INVALID_HANDLE
);
871 GlobalUnlock16( handle
);
872 GlobalFree16( handle
);
877 /***********************************************************************
878 * WritePrivateProfileSection (KERNEL.416)
880 BOOL16 WINAPI
WritePrivateProfileSection16( LPCSTR section
,
881 LPCSTR string
, LPCSTR filename
)
883 return WritePrivateProfileSectionA( section
, string
, filename
);
887 /***********************************************************************
888 * WriteProfileSection (KERNEL.417)
890 BOOL16 WINAPI
WriteProfileSection16( LPCSTR section
, LPCSTR keys_n_values
)
892 return WritePrivateProfileSection16( section
, keys_n_values
, "win.ini");
896 /***********************************************************************
897 * GetPrivateProfileSection (KERNEL.418)
899 INT16 WINAPI
GetPrivateProfileSection16( LPCSTR section
, LPSTR buffer
,
900 UINT16 len
, LPCSTR filename
)
902 return GetPrivateProfileSectionA( section
, buffer
, len
, filename
);
906 /***********************************************************************
907 * GetProfileSection (KERNEL.419)
909 INT16 WINAPI
GetProfileSection16( LPCSTR section
, LPSTR buffer
, UINT16 len
)
911 return GetPrivateProfileSection16( section
, buffer
, len
, "win.ini" );
915 /**************************************************************************
916 * GetFileAttributes (KERNEL.420)
918 DWORD WINAPI
GetFileAttributes16( LPCSTR name
)
920 return GetFileAttributesA( name
);
924 /**************************************************************************
925 * SetFileAttributes (KERNEL.421)
927 BOOL16 WINAPI
SetFileAttributes16( LPCSTR lpFileName
, DWORD attributes
)
929 return SetFileAttributesA( lpFileName
, attributes
);
933 /***********************************************************************
934 * GetDiskFreeSpace (KERNEL.422)
936 BOOL16 WINAPI
GetDiskFreeSpace16( LPCSTR root
, LPDWORD cluster_sectors
,
937 LPDWORD sector_bytes
, LPDWORD free_clusters
,
938 LPDWORD total_clusters
)
940 return GetDiskFreeSpaceA( root
, cluster_sectors
, sector_bytes
,
941 free_clusters
, total_clusters
);
944 /***********************************************************************
945 * FileCDR (KERNEL.130)
947 FARPROC16 WINAPI
FileCDR16(FARPROC16 x
)
949 FIXME("(%p): stub\n", x
);
950 return (FARPROC16
)TRUE
;