git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/4] mingw: move common functionality to win32.h

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Sep 27, 2008, 18:34 UTC
Message-ID
<200809272034.04931.johannes.sixt@telecom.at>
In-Reply-To
<20080927084301.GB21650@dpotapov.dyndns.org>
On Samstag, 27. September 2008, Dmitry Potapov wrote:
Show 19 quoted lines
> +static inline int get_file_attr(const char *fname,
> WIN32_FILE_ATTRIBUTE_DATA *fdata) +{
> +	if (GetFileAttributesExA(fname, GetFileExInfoStandard, fdata))
> +		return 0;
> +
> +	switch (GetLastError()) {
> +	case ERROR_ACCESS_DENIED:
> +	case ERROR_SHARING_VIOLATION:
> +	case ERROR_LOCK_VIOLATION:
> +	case ERROR_SHARING_BUFFER_EXCEEDED:
> +		return EACCES;
> +	case ERROR_BUFFER_OVERFLOW:
> +		return ENAMETOOLONG;
> +	case ERROR_NOT_ENOUGH_MEMORY:
> +		return ENOMEM;
> +	default:
> +		return ENOENT;
> +	}
> +}

I've long wished for a function that translates Win32 error codes to errno codes. It would be useful in a number of other places, too.

Here you introduce a new function get_file_attr() that is nothing but GetFileAttributesExA() followed by such an error code translation.

I suggest that we leave the original call to GetFileAttributesExA() alone and have a function win32_to_errno(void) that is just the switch statement above.

-- Hannes
Previous: Dmitry PotapovNext: Dmitry Potapov
Message 2 of 5 in “mingw: move common functionality to win32.h”
  1. 3/4 mingw: move common functionality to win32.hDmitry Potapov, Sep 27, 2008
  2. Johannes SixtSep 27, 2008
  3. Dmitry PotapovSep 27, 2008
  4. Johannes SixtSep 28, 2008
  5. Dmitry PotapovSep 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.