ruby/win32/file.h
Samuel Williams ea8a7287e2
Add support for sockaddr_un on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00

51 lines
1.4 KiB
C

#ifndef RUBY_WIN32_FILE_H
#define RUBY_WIN32_FILE_H
#ifndef IO_REPARSE_TAG_AF_UNIX
# define IO_REPARSE_TAG_AF_UNIX 0x80000023
#endif
enum {
MINIMUM_REPARSE_BUFFER_PATH_LEN = 100
};
/* License: Ruby's */
typedef struct {
ULONG ReparseTag;
USHORT ReparseDataLength;
USHORT Reserved;
union {
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[MINIMUM_REPARSE_BUFFER_PATH_LEN];
} SymbolicLinkReparseBuffer;
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
WCHAR PathBuffer[MINIMUM_REPARSE_BUFFER_PATH_LEN];
} MountPointReparseBuffer;
};
} rb_w32_reparse_buffer_t;
#define rb_w32_reparse_buffer_size(n) \
(sizeof(rb_w32_reparse_buffer_t) + \
sizeof(WCHAR)*((n)-MINIMUM_REPARSE_BUFFER_PATH_LEN))
int rb_w32_read_reparse_point(const WCHAR *path, rb_w32_reparse_buffer_t *rp,
size_t bufsize, WCHAR **result, DWORD *len);
int lchown(const char *path, int owner, int group);
int rb_w32_ulchown(const char *path, int owner, int group);
int fchmod(int fd, int mode);
#define HAVE_FCHMOD 0
UINT rb_w32_filecp(void);
WCHAR *rb_w32_home_dir(void);
#endif /* RUBY_WIN32_FILE_H */