Re: How to verify the path of an open file.



On 26 Jul 2007, David Tiktin <dtiktin@xxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

On 26 Jul 2007, max.trinitron@xxxxxxx wrote:

Under UNIX/Linux you open a file with

fopen("anyDirectory/MyFile" "r")

and when it succeeds you know that the filename (and path) of the
file opened is exactly what you requested (otherwise you get
NULL). Under Windows the search for a file is case insensitive.
You may just have opened the file "AnyDirectory/myFile".

In such a case I want to write an error message (This should lead
to better portability between UNIX/Linux and Windows).

Is there a simple way to verify that the right file (case
sensitive filename compare) has been opened.

You're probably better off asking in an Microsoft specific
newsgroup, but you might want to look at the GetLongPathName()
function. It gives you the case-preserved full path name. But
I'm not sure if that qualifies as a simple way ;-)

BTW, I forgot to mention that "anyDirectory/MyFile" and
"AnyDirectory/myFile" are the same file as is "ANYdirECTory/MYfile".
It's case insensitive! You can't have 2 file names that differ only
in case. You can check this yourself by trying to create 2 such
files.

Dave

--
D.a.v.i.d T.i.k.t.i.n
t.i.k.t.i.n [at] a.d.v.a.n.c.e.d.r.e.l.a.y [dot] c.o.m
.



Relevant Pages

  • Re: Transferring directory structure to Windows
    ... Transferring directory structure to Windows ... Filename collisions are a real threat but it should be ... whether FTP, tar, or whatever, you will only wind up ...
    (AIX-L)
  • Re: Characters allowed in short filenames
    ... fatgen103.doc seems to have a slightly below average proportion of bugs, but Windows doesn't completely agree with it. ... > My partial understanding is that short filenames are stored using the> OEM ... > As far as I can tell, code page 437 doesn't contain a ß character. ... > page is 850 then we are halfway towards allowing a short filename to ...
    (microsoft.public.development.device.drivers)
  • gnu grep in windows
    ... windows, it should not be. ... while also fixing this filename case sensitivity ... Fix this first by giving grep a directory to recurse into. ...
    (comp.windows.x.i386unix)
  • Re: Reading Text Files
    ... those questions that has far more to do with Windows than it has ... If the string doesn't represent such a filename, ... Consider, for example, MVS, in which filenames consist of digits, ... but *only* in the context of a PDS. ...
    (comp.lang.c)
  • Re: Characters allowed in short filenames
    ... fatgen103.doc is very clear in prohibiting lower-case letters from being stored in a short name. ... US Windows would be 437, ... the current default OEM code page is 437 and I create a new file then the ... page is 850 then we are halfway towards allowing a short filename to contain ...
    (microsoft.public.development.device.drivers)