# Ruby-ftp - directory vs file?

**URL:** <https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526>\
**Category:** Ruby\
**Created:** [June 4, 2008, 6:34pm UTC](https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526 "2008-06-04T18:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [June 4, 2008, 6:34pm UTC](https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526/1 "2008-06-04T18:34:10Z")

</div>

How do I find out whether “foobar” is a remote directory, or a remote  
file?

I don’t seem to find any trivial way to check this.  
Has this maybe been forgotten?

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [June 4, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526/2 "2008-06-04T22:15:50Z")

</div>

Solved it via .list (and help of someone else)

“drwxrwxrwx 2 web netscape 8192 Oct 29 2007 images”

The first pos indicates a dir.

However I think it would be nice if the ruby ftp class could be extended  
to allow easy checks like that, as does standard ruby ( i.e.  
File.directory? )

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [June 5, 2008, 10:07am UTC](https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526/3 "2008-06-05T10:07:58Z")

</div>

> Have you tried it on a Windows host?

No I haven’t. 🙂

In fact I dont know of a windows ftp host at all, all the ones I worked  
with are always unix-style, and for these the “ls -l” will work. I  
wonder if others will also end up doing the same checks as I did, or  
maybe noone else is using the ruby-ftp stuff… people should build more  
ruby-GUIs, there are plenty of things one can combine into these GUIs 😃

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [June 4, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/ruby-ftp-directory-vs-file/139526/4 "2008-06-04T22:57:14Z")

</div>

On Wednesday 04 June 2008 15:14:56 Marc H. wrote:

> “drwxrwxrwx 2 web netscape 8192 Oct 29 2007 images”
> 
> The first pos indicates a dir.

By convention, I think. That’s a Unix-style mask, as you would get  
with ‘ls -l’. Have you tried it on a Windows host?

I’m not sure there’s anything built into the FTP protocol to show that  
it’s a  
directory.
