--cNdxnHkX5QqsyA0e
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Aug 05, 2004 at 09:46:53AM +0900, Matthew Margolis wrote:
> I am trying to figure out how to open up a text file in a subdirectory=20
> of my programs main directory.  The file I want is in the subdirectory=20
> labeled text.  I get a "Permission  denied - text/" message when=20
> attempting to run the code found below.
>=20
> campershash =3D Hash.new
> Dir.entries("text").each do |textfilename|
>   campershash["#{textfilename.chop.chop.chop.chop}"] =3D=20
> File.open("text/" + "#{textfilename}") { |f| f.gets(nil) }
> end
>=20
> The Dir.entries call works finer but on the next line when I go to open=
=20
> up each text file in the text directory I run into problems.  I am=20
> running the program on windows XP with administrator privileges so I am=
=20
> unclear as to why I am having permission issues.
>=20

You're probably trying to open a directory (. and .. in 'text/'). Try
one of the two examples below:

campershash =3D {}
Dir.entries("text").each do |textfilename|
    # Don't know why you're using four chop's - but I've replaced them
    # with 'strip' to make the example more readable.
    campershash[textfilename.strip] =3D=20
        File.read(File.join("text", textfilename)) if File.file?(textfilena=
me)
end

or

campershash =3D {}
Dir["text/*"].each do |f|
    campershash[f.strip] =3D File.read(f)
end

//Anders


--=20
=2E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
=2E Anders Engstr=F6m         aengstrom / gnejs.net
=2E http://www.gnejs.net    PGP-Key: ED010E7F
=2E [Your mind is like an umbrella. It doesn't work unless you open it.] =
=20


--cNdxnHkX5QqsyA0e
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBEbyquNLLbe0BDn8RAnuaAJ9KdNz4zh54+MhrfA0daweNtZhomgCgj2eX
3yWy8dQW5YFabVrunVTsk1Y=
=QbS3
-----END PGP SIGNATURE-----

--cNdxnHkX5QqsyA0e--

On Thu, Aug 05, 2004 at 09:46:53AM +0900, Matthew Margolis wrote:
> I am trying to figure out how to open up a text file in a subdirectory=20
> of my programs main directory.  The file I want is in the subdirectory=20
> labeled text.  I get a "Permission  denied - text/" message when=20
> attempting to run the code found below.
>=20
> campershash =3D Hash.new
> Dir.entries("text").each do |textfilename|
>   campershash["#{textfilename.chop.chop.chop.chop}"] =3D=20
> File.open("text/" + "#{textfilename}") { |f| f.gets(nil) }
> end
>=20
> The Dir.entries call works finer but on the next line when I go to open=
=20
> up each text file in the text directory I run into problems.  I am=20
> running the program on windows XP with administrator privileges so I am=
=20
> unclear as to why I am having permission issues.
>=20

You're probably trying to open a directory (. and .. in 'text/'). Try
one of the two examples below:

campershash =3D {}
Dir.entries("text").each do |textfilename|
    # Don't know why you're using four chop's - but I've replaced them
    # with 'strip' to make the example more readable.
    campershash[textfilename.strip] =3D=20
        File.read(File.join("text", textfilename)) if File.file?(textfilena=
me)
end

or

campershash =3D {}
Dir["text/*"].each do |f|
    campershash[f.strip] =3D File.read(f)
end

//Anders


--=20
=2E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
=2E Anders Engstr=F6m         aengstrom / gnejs.net
=2E http://www.gnejs.net    PGP-Key: ED010E7F
=2E [Your mind is like an umbrella. It doesn't work unless you open it.] =
=20

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBEbyquNLLbe0BDn8RAnuaAJ9KdNz4zh54+MhrfA0daweNtZhomgCgj2eX
3yWy8dQW5YFabVrunVTsk1Y=
=QbS3
-----END PGP SIGNATURE-----