This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FILE_FLAG_POSIX_SEMANTICS


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]