Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2458 > unrolled thread
| Started by | "Kalman H." <kalmanh@gmail.com> |
|---|---|
| First post | 2011-04-07 09:03 -0500 |
| Last post | 2011-04-07 11:10 -0700 |
| Articles | 6 — 6 participants |
Back to article view | Back to comp.lang.ruby
Windows directories not recognized by ruby? "Kalman H." <kalmanh@gmail.com> - 2011-04-07 09:03 -0500
Re: Windows directories not recognized by ruby? Nikolai Weibull <now@bitwi.se> - 2011-04-07 09:23 -0500
Re: Windows directories not recognized by ruby? paul h <paul@hollyer.me.uk> - 2011-04-07 07:28 -0700
Re: Windows directories not recognized by ruby? Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-04-07 09:28 -0500
Re: Windows directories not recognized by ruby? Regis d'Aubarede <regis.aubarede@gmail.com> - 2011-04-07 10:47 -0500
Re: Windows directories not recognized by ruby? koulikoff <koulikoff@gmail.com> - 2011-04-07 11:10 -0700
| From | "Kalman H." <kalmanh@gmail.com> |
|---|---|
| Date | 2011-04-07 09:03 -0500 |
| Subject | Windows directories not recognized by ruby? |
| Message-ID | <043fe95b0b6678577d4c637390b94bc2@ruby-forum.com> |
What's wrong with this code? C:\>mkdir test_ruby C:\>irb irb(main):001:0> File.directory? "c:" => true irb(main):002:0> File.directory? "c:\test_ruby" => false irb(main):003:0> Thanks for any ideas in advance, -Kalman -- Posted via http://www.ruby-forum.com/.
[toc] | [next] | [standalone]
| From | Nikolai Weibull <now@bitwi.se> |
|---|---|
| Date | 2011-04-07 09:23 -0500 |
| Message-ID | <BANLkTimGO25+C2yBADsyEVVfoN3D+_7HKw@mail.gmail.com> |
| In reply to | #2458 |
On Thu, Apr 7, 2011 at 16:03, Kalman H. <kalmanh@gmail.com> wrote: > irb(main):002:0> File.directory? "c:\test_ruby" You may want to escape your reverse solidus (backslash), or, better yet, use a solidus (slash, virgule) instead.
[toc] | [prev] | [next] | [standalone]
| From | paul h <paul@hollyer.me.uk> |
|---|---|
| Date | 2011-04-07 07:28 -0700 |
| Message-ID | <5001be3d-a2ec-4c46-be8e-4cfc3e9b7f8a@v16g2000vbq.googlegroups.com> |
| In reply to | #2458 |
On Apr 7, 3:03 pm, "Kalman H." <kalm...@gmail.com> wrote: > What's wrong with this code? > > C:\>mkdir test_ruby > > C:\>irb > irb(main):001:0> File.directory? "c:" > => true > irb(main):002:0> File.directory? "c:\test_ruby" > => false > irb(main):003:0> > > Thanks for any ideas in advance, > > -Kalman > > -- > Posted viahttp://www.ruby-forum.com/. It's the way Ruby handles your strings. You are using double quotes, so you need to escape the backslash. If you use single quotes, you can use the single backslash. Look at the following: irb(main):001:0> File.directory? "C:" => true irb(main):002:0> File.directory? "C:\Users" => false irb(main):003:0> File.directory? "C:\\Users" => true irb(main):004:0> File.directory? 'C:\Users' => true HTH Paul
[toc] | [prev] | [next] | [standalone]
| From | Phillip Gawlowski <cmdjackryan@googlemail.com> |
|---|---|
| Date | 2011-04-07 09:28 -0500 |
| Message-ID | <BANLkTi=23=Eh64vNz9qgs60Odrjvi50JcQ@mail.gmail.com> |
| In reply to | #2458 |
On Thu, Apr 7, 2011 at 4:03 PM, Kalman H. <kalmanh@gmail.com> wrote: > What's wrong with this code? > > C:\>mkdir test_ruby > > C:\>irb > irb(main):001:0> File.directory? "c:" > => true > irb(main):002:0> File.directory? "c:\test_ruby" > => false > irb(main):003:0> > The \ is an escape character, so you are actually checking for "c: est_ruby" (\t is is the escape sequence for a tab character) Either try File.directory? "c:\\test_ruby" or File.directory? "c:/test_ruby" Windows NT *at least* since Vista, but probably XP already, and maybe even the original NT 3.51, support the forward slash in the command line. -- Phillip Gawlowski Though the folk I have met, (Ah, how soon!) they forget When I've moved on to some other place, There may be one or two, When I've played and passed through, Who'll remember my song or my face.
[toc] | [prev] | [next] | [standalone]
| From | Regis d'Aubarede <regis.aubarede@gmail.com> |
|---|---|
| Date | 2011-04-07 10:47 -0500 |
| Message-ID | <b92734a5072cb2e61434fddfb911d4a9@ruby-forum.com> |
| In reply to | #2463 |
> Windows NT *at least* since Vista, but probably XP already, and maybe > even the original NT 3.51, support the forward slash in the command > line. ForwardSlash works since MSDOS ! From wikipedia "Backslash" : "The Windows API can accept either the backslash or slash to separate directory and file components of a path, but the Microsoft convention is to use a backslash, and APIs that return paths put backslash in.[7] MS-DOS 2.0 copied the hierarchical file system from Unix and thus used the forward slash, but (possibly on the insistence of IBM) added the backslash to allow paths to be typed into the command shell while retaining compatibility with MS-DOS 1.0 and CP/M where the slash was the command-line option indicator (i.e. as in typing "dir/w" to give the "wide" option to the "dir" command).[8] Although the command shell was the only part of MS-DOS that required this, the use of backslash in filenames was propagated to most other parts of the user interface" -- Posted via http://www.ruby-forum.com/.
[toc] | [prev] | [next] | [standalone]
| From | koulikoff <koulikoff@gmail.com> |
|---|---|
| Date | 2011-04-07 11:10 -0700 |
| Message-ID | <0ea5da2a-c565-448e-8b27-608e035a7de6@m7g2000vbq.googlegroups.com> |
| In reply to | #2458 |
On Apr 7, 6:03 pm, "Kalman H." <kalm...@gmail.com> wrote: > What's wrong with this code? > > C:\>mkdir test_ruby > > C:\>irb > irb(main):001:0> File.directory? "c:" > => true > irb(main):002:0> File.directory? "c:\test_ruby" > => false > irb(main):003:0> > > Thanks for any ideas in advance, > > -Kalman > > -- > Posted viahttp://www.ruby-forum.com/. You should use File.directory? File.join(%w[c: test_ruby])
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.ruby
csiph-web