[Mono-list] GetDirectories, glob, and high ACSII characters
Elan Feingold
efeingold@mn.rr.com
Mon, 10 Mar 2003 07:34:58 -0600
This is a multi-part message in MIME format.
------=_NextPart_000_0001_01C2E6D7.8D94EDE0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi,
Has anyone else noticed that the GetDirectories code (and probably file
listing code) doesn't return directories with "foreign" characters
(accented letters, etc.)?
I traced this down to the call to glob() which, when compiled in a test
C program, returns all the directories, but for some reason within Mono
doesn't.
Is this some locale related strangeness??????
Best regards,
-elan
DirectoryInfo dirInfo = new DirectoryInfo(dir);
DirectoryInfo[] subDirs = dirInfo.GetDirectories();
foreach (DirectoryInfo subDir in subDirs)
{
Console.WriteLine("Directory is: {0}.", subDir.Name);
}
This code lists the offending directory in a small test program, but not
when embedded into the Mono source:
glob_t globbuf;
int i = 0;
glob("/mnt/trove/Music/Blonde Redhead/*", 0, NULL, &globbuf);
printf("Matches: %d\n", globbuf.gl_pathc);
for (i=0; i<globbuf.gl_pathc; i++)
printf(" -> '%s'\n", globbuf.gl_pathv[i]);
------=_NextPart_000_0001_01C2E6D7.8D94EDE0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Georgia;
panose-1:2 4 5 2 5 4 5 2 3 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{font-family:Georgia;
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>Hi,</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>Has anyone else noticed that the GetDirectories =
code (and probably
file listing code) doesn’t return directories with =
“foreign”
characters (accented letters, etc.)?</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>I traced this down to the call to glob() which, =
when
compiled in a test C program, returns all the directories, but for some =
reason
within Mono doesn’t.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>Is this some locale related =
strangeness??????</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>Best regards,</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>-elan</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
DirectoryInfo dirInfo
=3D new DirectoryInfo(dir);</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
DirectoryInfo[]
subDirs =3D dirInfo.GetDirectories();</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> foreach =
(DirectoryInfo
subDir in subDirs)</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
{</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> &nbs=
p;
Console.WriteLine("Directory is: {0}.", =
subDir.Name);</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
}</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>This code lists the offending directory in a small =
test
program, but not when embedded into the Mono source:</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> glob_t =
globbuf;</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> int i =3D 0;</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
glob("/mnt/trove/Music/Blonde
Redhead/*", 0, NULL, &globbuf);</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> printf("Matches: =
%d\n", globbuf.gl_pathc);</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> for (i=3D0; =
i<globbuf.gl_pathc; i++)</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'> =
printf("
-> '%s'\n", globbuf.gl_pathv[i]);</span></font></p>
</div>
</body>
</html>
------=_NextPart_000_0001_01C2E6D7.8D94EDE0--