X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Thu, 10 Nov 2011 10:58:36 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.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@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <135801cc9a69$f73ceaf0$e5b6c0d0$@vaultnow.com> <4EB30DF9.2080006@cwilson.fastmail.fm> <20111104084619.GM9159@calimero.vinschen.de> <029901cc9f68$41108a80$c3319f80$@vaultnow.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <029901cc9f68$41108a80$c3319f80$@vaultnow.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.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

