[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'>&nbsp;</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&#8217;t return directories with =
&#8220;foreign&#8221;
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'>&nbsp;</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&#8217;t.</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;</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'>&nbsp;</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'>&nbsp;</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'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
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'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
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'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;
Console.WriteLine(&quot;Directory is: {0}.&quot;,&nbsp; =
subDir.Name);</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;</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'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp; glob_t =
globbuf;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp; 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'>&nbsp;&nbsp;&nbsp; </span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp; =
glob(&quot;/mnt/trove/Music/Blonde
Redhead/*&quot;, 0, NULL, &amp;globbuf);</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp; printf(&quot;Matches: =
%d\n&quot;, globbuf.gl_pathc);</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DGeorgia><span =
style=3D'font-size:10.0pt;
font-family:Georgia'>&nbsp;&nbsp;&nbsp; for (i=3D0; =
i&lt;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'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
printf(&quot;
-&gt; '%s'\n&quot;, globbuf.gl_pathv[i]);</span></font></p>

</div>

</body>

</html>

------=_NextPart_000_0001_01C2E6D7.8D94EDE0--