delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/11/10/04:59:28

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 10 Nov 2011 10:58:36 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Possible Bug (clarification) in Cygwin 1.7.5 -- findfirstfile (and findnextfile) yeild bad cfilename when file names have special characters. Works in cygwin 1.5, fails in 1.7
Message-ID: <20111110095836.GO15154@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <135801cc9a69$f73ceaf0$e5b6c0d0$@vaultnow.com> <4EB30DF9 DOT 2080006 AT cwilson DOT fastmail DOT fm> <20111104084619 DOT GM9159 AT calimero DOT vinschen DOT de> <029901cc9f68$41108a80$c3319f80$@vaultnow.com>
MIME-Version: 1.0
In-Reply-To: <029901cc9f68$41108a80$c3319f80$@vaultnow.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Nov  9 22:18, Leon Vanderploeg wrote:
> Many thanks to Charles and Corinna for the help.  I have modified the
> code to use the POSIX functions.  I still have one problem I cannot
> seem to conquer.  
> 
> I need to be able to read and write the (yes, I know it's evil)
> archive bit.  Unless there is a POSIX function (which I seriously
> doubt) for these items, I am locked into the windows APIs.
> 
> I have read and re-read the Cygwin documentation on
> internationalization at least 6 times and I cannot figure out what I
> need to do to get this to work.  I have tried numerous combinations of
> environment variables and locale settings in the code, but none of
> them work.  The windows API fails to find the file specified.  I just
> want US English that can handle the extended character set to the
> windows APIs.  In this case, let's use the example of the copyright
> symbol (the small c with a circle around it).  What needs to be set in
> the environment, and what needs to be set in the C code to handle
> these characters correctly?

Nothing.  Just use always the UNICODE API, rather than the ANSI API:

  #include <sys/cygwin.h>

  DWORD
  my_GetFileAttributes (const char *cygwin_multibyte_filename)
  {
    DWORD attr = INVALID_FILE_ATTRIBUTES;
    PWCHAR w32_filename = cygwin_create_path (CCP_POSIX_TO_WIN_W,
					      cygwin_multibyte_filename);
    if (w32_filename)
      {
	attr = GetFileAttributes (w32_filename);
	free (w32_filename);
      }
    return attr;
  }


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019