delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2010/02/28/04:01:22

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
NNTP-Posting-Date: Sun, 28 Feb 2010 02:40:48 -0600
From: "Robbie Hatley" <see DOT my DOT signature AT for DOT my DOT contact DOT info>
Newsgroups: comp.os.msdos.djgpp
References: <2PydnQe72P4H_BrWnZ2dnUVZ_vmdnZ2d AT giganews DOT com> <hmbvg7$ieq$1 AT speranza DOT aioe DOT org>
Subject: Re: Bug in findfirst/findnext: mangles certain characters.
Date: Sun, 28 Feb 2010 00:43:25 -0800
Organization: Tustin Free Zone
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1983
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1983
Message-ID: <Br-dnQ3aTcaMsRfWnZ2dnUVZ_uSdnZ2d@giganews.com>
Lines: 142
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-aRwLrK1ClbubifDLfR53F2pV2YKCrwcfA/YFxNwv+TlGSLugMtueeyYbT5mQQaswJ1YhtVBa6rTNYBl!fhch4yYwSbzNTahkLj4IA6pxgqEoQBtrTHxQNkXrWJBDhEH8ej8v7Dv9MwU4dBeNUQdzmJxvow==
X-Complaints-To: abuse AT giganews DOT com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
Bytes: 6214
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Rod Pemberton" wrote:

> "Robbie Hatley" wrote:
> >
> > This is broken, because it causes rename attempts to fail,
> > because no files actually exist with the altered versions
> > of their names given by findfirst/findnext.
> >
>
> I'm not sure if this suggestion will help or not.  At best,
> if it works for you, it's a work around, not a fix.
> For a personal utility I wrote, I chose to use SFNs via
> _dos_findfirst and _dos_findnext.

Never heard of those.  Let me look them up in "libc.html".

:::reads:::

Ok, that might actually be a way to go.  I could rewrite my
LoadFileList() function (in my personal library) to use that,
hence bypassing all the issues with file names in various
encodings, since every file has a DOS SFN which is a simple
8-character-long ASCII name, I presume.

> I seem to recall having problems with findfirst and findnext.
> After I've _dos_findfirst/next returns the correct SFN, I call
> the LFN API 0x7160 function via DPMI to get the correct LFN.

That's more involved than I've ever gone.  But might be worthwhile
to learn how to do that.

> At which point, you may be able to use rename() or
> _rename() or LFN API 0x7156 function to rename, assuming the LFN
> API correctly returns these characters...

As long as I can come up with "from" and "to" names that
rename() actually recognizes, and as long as the "from" name
ACTUALLY IS THE NAME OF THE FILE TO BE RENAMED, that should work.

> Personally, I would like to experiment with this.  I'm not part
> of the DJGPP development team.  But, is it too much to ask if
> you could post an example that demonstrates a failure?

I could, but if you want something that actually compiles, I'd have
to paste dozens of pages of code into this post.  I'd have to paste
the entireity of several files:
rhdefines.h
rhmath.h
rhregex.h
rhutil.h
rhdir.h
librh.a (as a binary attachment)
rhdir.cpp (simple directory-listing program)

Simpler to just write somthing that uses findfirst()/findnext()
in a loop, reads all the file records in current directory,
and prints the Long File Name field of each record.

Something like:

   for
   (
      done = findfirst(Wildcard.c_str(), &FileBlock, Flags);
      not done;
      done = findnext(&FileBlock)
   )
   {
      cout << FileBlock.ff_name << endl;
   }

> And, is this in pure DOS or a Windows command console?  98? XP?

Windows 2000 Professional, with all the latest service packs and
updates.  All my personal utility programs (which I write both
for programming practice, and to solve a myriad of file management
issues on my computer) operate in the Windows 2000 command console,
process cmd.exe, which also calls ntvdm.exe (NT Virtual Dos Machine).

> Which DJGPP version? 2.03? 2.04?

Latest.

> Do I need to set a different code page?

Code pages.  Hmmm.

::: experiments :::

::: does double take :::

Whoa, I noticed that my programs work much better in code page
437 than nearly any other.  Which is the opposite of what I'd
expect, because that's pretty far removed from iso-8859-1.

I'd been using code page 1252 mostly, but I think I'll take
the "chcp 1252" line out of my "dos_init.bat" file, which
is invoked when I click any of the command-console icons on
my toolbar.  The default, 437, seems to work much better.

These code pages are not working the way I expect at all,
and are causing findfirst()/findnext() to give drastically
different versions of the names of my files from what
"dir" gives.  Except for 437, which is giving many fewer
errors.  Still gives a few, though.

> How did you create the names with the problematic characters
> in the first place?

Acquired from the Internet, for one thing.  Go here:
http://picasaweb.google.com/lh/explore#
Search for "Italy scenic pictures" or "Spain scenic pictures".

Or, if you're really daring and want to see some file names
written (backwards!!!) in Hebrew, search for "Israel scenic
pictures".  I have some files with names in Japanese, Chinese,
Russian, Malayalam, etc.  Some of the glyphs look more like
cooked spagetti than letters to my Western eye.  But the Internet
is truly a global place, and many people write (and name files)
like this: "??????? ?????? ????" or like this: "??????? ????".

Also, you can type any iso-8859-1 characters you want like so:
1. Hold down the "Alt" key.
2. Type 0 (the zero key) followed by the 3-digit decimal
   iso-8859-1 code for the glyph you want.
3. Release "Alt" key
I do that to create pathological test files for my file-utility
programs.  Like so:

"Fíle-Nàme-Wíth-Måny-ïsõ-8859-1-Lëttêrs-Ìn-Ít.txt"

Try renaming THAT file using findfirst/findnext and rename().
It won't work.  (Findfirst will turn "Ìn-Ít" to "In-It",
for one thing.  rename() will then complain "no such file".)

-- 
Cheers,
Robbie Hatley
lonewolf at well dot com
www dot well dot com slant tilde lonewolf slant


- Raw text -


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