4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 18:19:08 +08:00

Cygwin: fhandler_base::set_name_from _handle: new method

This is based on a new static member function dtable::handle_to_fn,
which was previously a static function in dtable.cc.
This commit is contained in:
Ken Brown 2020-11-16 15:06:48 -05:00
parent 91ce3d3fd7
commit b9feec71ff
4 changed files with 18 additions and 4 deletions

View File

@ -31,8 +31,6 @@ details. */
static const DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
STD_ERROR_HANDLE};
static bool handle_to_fn (HANDLE, char *);
#define WCLEN(x) ((sizeof (x) / sizeof (WCHAR)) - 1)
static const char unknown_file[] = "some disk file";
static const WCHAR DEV_NULL[] = L"\\Device\\Null";
@ -937,8 +935,8 @@ decode_tty (char *buf, WCHAR *w32)
/* Try to derive posix filename from given handle. Return true if
the handle is associated with a cygwin tty. */
static bool
handle_to_fn (HANDLE h, char *posix_fn)
bool
dtable::handle_to_fn (HANDLE h, char *posix_fn)
{
tmp_pathbuf tp;
ULONG len = 0;

View File

@ -78,6 +78,8 @@ public:
void fixup_before_fork (DWORD win_proc_id);
void lock () {lock_process::locker.acquire ();}
void unlock () {lock_process::locker.release ();}
static bool handle_to_fn (HANDLE, char *);
};
fhandler_base *build_fh_dev (const device&, const char * = NULL);

View File

@ -29,6 +29,7 @@ details. */
#include "shared_info.h"
#include <asm/socket.h>
#include "cygwait.h"
#include "tls_pbuf.h"
#define MAX_OVERLAPPED_WRITE_LEN (64 * 1024 * 1024)
#define MIN_OVERLAPPED_WRITE_LEN (1 * 1024 * 1024)
@ -135,6 +136,18 @@ fhandler_base::set_name (path_conv &in_pc)
pc << in_pc;
}
/* Preliminary version. */
void
fhandler_base::set_name_from_handle ()
{
tmp_pathbuf tp;
char *name = tp.c_get ();
name[0] = '\0';
dtable::handle_to_fn (get_handle (), name);
set_name (cstrdup (name));
}
char *fhandler_base::get_proc_fd_name (char *buf)
{
IO_STATUS_BLOCK io;

View File

@ -237,6 +237,7 @@ class fhandler_base
pc.set_posix (s);
pc.set_path (s);
}
virtual void set_name_from_handle ();
int error () const {return pc.error;}
void set_error (int error) {pc.error = error;}
bool exists () const {return pc.exists ();}