#include "config.h"
#include "compat.h"
#include "debug.h"
Go to the source code of this file.
◆ _POSIX_SOURCE
◆ compat_catpath()
Definition at line 324 of file compat.c.
325{
327#ifdef WANT_WIN32_UNICODE
328 wchar_t *wprefix =
NULL;
329 wchar_t *wpath =
NULL;
330 wchar_t *locwret =
NULL;
331
332
333
334
335
336
337
341
343 goto catpath_end;
344 wprefix = u2wpath(
prefix);
345 wpath = u2wpath(
path);
347 goto catpath_end;
348
349
350
353 if(mypac)
354 {
355 debug(
"Actually calling PathAllocCombine!");
356 mypac(wprefix, wpath, 1, &locwret);
357 }
358 else
359 {
360
361
363 if(locwret)
365 }
366 ret = w2upath(locwret);
367
368catpath_end:
372#else
373 size_t len, prelen, patlen;
374
379
383 {
384 size_t off=0;
387 ret[prelen+(off++)] =
'/';
390 }
391#endif
393}
ACPI_SIZE strlen(const char *String)
#define GetProcAddress(x, y)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
#define memcpy(s1, s2, n)
Character const *const prefix
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
◆ compat_close()
Closing a file handle can be platform specific. This function takes a file descriptor that is to be closed.
- Parameters
-
[in] | infd | File descriptor to be closed. |
- Returns
- 0 if the file was successfully closed. A return value of -1 indicates an error.
Definition at line 253 of file compat.c.
254{
255#if (defined(WIN32) && !defined (__CYGWIN__))
257#else
259#endif
260}
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
◆ compat_dirclose()
Definition at line 481 of file compat.c.
482{
484 {
486#ifdef WANT_WIN32_UNICODE
488#else
490#endif
492 }
493}
BOOL WINAPI FindClose(HANDLE hFindFile)
int __cdecl closedir(DIR *)
◆ compat_diropen()
Definition at line 431 of file compat.c.
432{
439#ifdef WANT_WIN32_UNICODE
441 {
443 wchar_t *wpattern;
445 wpattern = u2wlongpath(
pattern);
446 if(wpattern)
447 {
450 {
451
454 }
455 else
457 }
460 }
461#else
464 {
467 }
468#endif
470 {
473 {
476 }
477 }
479}
#define INVALID_HANDLE_VALUE
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
DIR *__cdecl opendir(const char *)
◆ compat_fclose()
Definition at line 262 of file compat.c.
263{
265}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
◆ compat_fdopen()
Also fdopen to avoid having to define POSIX macros in various source files.
Definition at line 248 of file compat.c.
249{
251}
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
◆ compat_fopen()
Definition at line 218 of file compat.c.
219{
221#ifdef WANT_WIN32_UNICODE
223 wchar_t *wname =
NULL;
224 wchar_t *wmode =
NULL;
225
227 if(!wname)
228 goto fopen_fallback;
230 if( (wmode ==
NULL) || (
cnt == 0))
231 goto fopen_fallback;
232
235
236fopen_fallback:
237#endif
239#ifdef WANT_WIN32_UNICODE
240
241fopen_ok:
244#endif
246}
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
◆ compat_getenv()
Definition at line 52 of file compat.c.
53{
55#ifdef WANT_WIN32_UNICODE
57 wchar_t *wname =
NULL;
59 {
64 }
65#else
69#endif
71}
static LPCWSTR LPCWSTR LPCWSTR env
_Check_return_ _CRTIMP wchar_t *__cdecl _wgetenv(_In_z_ const wchar_t *_VarName)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
◆ compat_isdir()
Definition at line 395 of file compat.c.
396{
398#ifdef WANT_WIN32_UNICODE
399 wchar_t *wpath;
400 wpath = u2wlongpath(
path);
401 if(wpath)
402 {
407 }
408#else
411 {
414 }
415#endif
417}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
#define FILE_ATTRIBUTE_DIRECTORY
#define INVALID_FILE_ATTRIBUTES
◆ compat_nextdir()
Definition at line 529 of file compat.c.
530{
533#ifdef WANT_WIN32_UNICODE
535 {
538 {
542 }
543 }
544#else
545 {
548 {
551 if(fullpath && !
stat(fullpath, &fst) &&
S_ISDIR(fst.st_mode))
552 {
555 }
557 }
558 }
559#endif
561}
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
struct dirent *__cdecl readdir(DIR *)
◆ compat_nextfile()
Definition at line 495 of file compat.c.
496{
499#ifdef WANT_WIN32_UNICODE
501 {
504 {
508 }
509 }
510#else
511 {
514 {
517 if(fullpath && !
stat(fullpath, &fst) &&
S_ISREG(fst.st_mode))
518 {
521 }
523 }
524 }
525#endif
527}
◆ compat_open()
Opening a file handle can be different. This function here is defined to take a path in native encoding (ISO8859 / UTF-8 / ...), or, when MS Windows Unicode support is enabled, an UTF-8 string that will be converted back to native UCS-2 (wide character) before calling the system's open function.
- Parameters
-
[in] | wptr | Pointer to wide string. |
[in] | mbptr | Pointer to multibyte string. |
- Returns
- file descriptor (>=0) or error code.
Definition at line 181 of file compat.c.
182{
184#if defined (WANT_WIN32_UNICODE)
185 wchar_t *frag =
NULL;
186
188
189 if(!frag)
190 goto open_fallback;
191
192
195 goto open_ok;
196
197open_fallback:
198#endif
199
200#if (defined(WIN32) && !defined (__CYGWIN__))
201
202
204#else
206#endif
207
208#if defined (WANT_WIN32_UNICODE)
209open_ok:
211#endif
212
214}
_CRTIMP int __cdecl _wopen(const wchar_t *_Filename, int _OpenFlag,...)
_CRTIMP int __cdecl _open(const char *_Filename, int _OpenFlag,...)
◆ unintr_read()
Definition at line 631 of file compat.c.
632{
633 size_t got = 0;
635 {
638 break;
640 got += part;
641 }
642 return got;
643}
static unsigned char bytes[4]
◆ unintr_write()
Definition at line 616 of file compat.c.
617{
618 size_t written = 0;
620 {
623 break;
625 written += part;
626 }
627 return written;
628}