delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/11/21:58:36

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <007a01c0da87$42940190$7f291518@CX535256E>
From: "Barubary" <barubary AT home DOT com>
To: <cygwin AT cygwin DOT com>
Subject: FILE_FLAG_POSIX_SEMANTICS
Date: Fri, 11 May 2001 19:00:02 -0700
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

Why doesn't Cygwin allow the creation of files whose names differ only in
case?  The OS and file system support it, after all, using
FILE_FLAG_POSIX_SEMANTICS with CreateFileW (or CreateFileA).  An example
program that does this is below, but I highly doubt it'll compile under
cygwin (I used M$VC-- 6).

I don't know if it'll work on Win9x (I doubt it) or under NT with a
FAT12/16/32 filesystem, because I have no easy way to try it.  If you do try
it on Win9x, don't forget that CreateFileW doesn't exist - change it to
CreateFileA.

When you have multiple files with the same case, you must use the flag in
order to open the correct one.  Otherwise, it finds the first one and opens
that.

By the way, cmd.exe has a minor bug in del - "del asdf" deletes both files
("rm asdf" does not - it deletes the first file it finds, in this case ASDF
for me).  This is apparently because it does wildcard matching even when
there's no asterisks or question marks.

-- Barubary

#define NOGDI
#define NOUSER
#include <windows.h>
#include <stdio.h>

typedef wchar_t wchar;

int wmain(void)
{
 DWORD dummy;
 HANDLE file;

 if ((file = CreateFileW(L"asdf", GENERIC_WRITE, 0, NULL, CREATE_NEW,
  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_POSIX_SEMANTICS, NULL)) ==
  INVALID_HANDLE_VALUE)
 {
  wprintf(L"error 1\n");
  return 1;
 }

 WriteFile(file, "asdf", 4, &dummy, NULL);

 CloseHandle(file);

 if ((file = CreateFileW(L"ASDF", GENERIC_WRITE, 0, NULL, CREATE_NEW,
  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_POSIX_SEMANTICS, NULL)) ==
  INVALID_HANDLE_VALUE)
 {
  wprintf(L"error 2\n");
  return 1;
 }

 WriteFile(file, "ASDF", 4, &dummy, NULL);

 CloseHandle(file);

 return 0;
}



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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