From 18e070ac54fd583e435b2200fed805fa94a4268d Mon Sep 17 00:00:00 2001 From: Andrew Innes Date: Mon, 18 Dec 2000 23:50:26 +0000 Subject: [PATCH] (w32_strerror): New function. --- src/w32.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/w32.c b/src/w32.c index abf2db6580b..5e9b8313ddb 100644 --- a/src/w32.c +++ b/src/w32.c @@ -97,6 +97,25 @@ extern Lisp_Object Vw32_generate_fake_inodes; extern Lisp_Object Vw32_get_true_file_attributes; extern Lisp_Object Vw32_num_mouse_buttons; + +/* Equivalent of strerror for W32 error codes. */ +char * +w32_strerror (int error_no) +{ + static char buf[500]; + + if (error_no == 0) + error_no = GetLastError (); + + buf[0] = '\0'; + if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, + error_no, + 0, /* choose most suitable language */ + buf, sizeof (buf), NULL)) + sprintf (buf, "w32 error %u", error_no); + return buf; +} + static char startup_dir[MAXPATHLEN]; /* Get the current working directory. */ -- 2.39.2