[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

...and deleting directories?

Kurt Euler

10/8/2003 6:15:00 AM

All-

Again related to the question I just posed: Is there a way to delete a directory structure on an NT machine from within Ruby code? I should think some syntax that includes rmdir would apply.

Thanks again!

-Kurt Euler

4 Answers

nobu.nokada

10/8/2003 11:51:00 AM

0

Hi,

At Wed, 8 Oct 2003 15:15:29 +0900,
Kurt Euler wrote:
> Again related to the question I just posed: Is there a way to
> delete a directory structure on an NT machine from within
> Ruby code? I should think some syntax that includes rmdir
> would apply.

From [ruby-talk:83752]:

At Wed, 8 Oct 2003 15:42:04 +0900,
Gavin Sinclair wrote:
> require 'fileutils'
>
> FileUtils.rm_rf(directory) # trash a directory tree
^^^^^^^^^^^^^^^^

--
Nobu Nakada

Christoph

10/8/2003 7:08:00 PM

0

nobu.nokada wrote: wrote
....
> Gavin Sinclair wrote:
> > require 'fileutils'
> >
> > FileUtils.rm_rf(directory) # trash a directory tree
> ^^^^^^^^^^^^^^^^

This doesn't work if the directory "directory" itself isn't readable.

Here is an example I created with cygwin (if cygwin isn't handy use
the explorer permission window or Microsoft's own xcaclcs tool).

$mkdir directory; chmod -w directory

E:\Ruby\Scripts>ruby -r fileutils -e "FileUtils.rm_rf('directory')"
E:/Ruby/lib/ruby/1.8/fileutils.rb:583:in `rmdir': Permission denied -
directory (Errno::EACCES)
from E:/Ruby/lib/ruby/1.8/fileutils.rb:583:in `remove_dir'
from E:/Ruby/lib/ruby/1.8/fileutils.rb:534:in `rm_r'
from E:/Ruby/lib/ruby/1.8/fileutils.rb:526:in `each'
from E:/Ruby/lib/ruby/1.8/fileutils.rb:526:in `rm_r'
from E:/Ruby/lib/ruby/1.8/fileutils.rb:550:in `rm_rf'
from -e:1


/Christoph


Christoph

10/8/2003 7:33:00 PM

0

Christoph wrote:

....
> >
> E:\Ruby\Scripts>ruby -r fileutils -e "FileUtils.rm_rf('directory')"
> E:/Ruby/lib/ruby/1.8/fileutils.rb:583:in `rmdir': Permission denied -
> directory (Errno::EACCES)
> from E:/Ruby/lib/ruby/1.8/fileutils.rb:583:in `remove_dir'
> from E:/Ruby/lib/ruby/1.8/fileutils.rb:534:in `rm_r'
> from E:/Ruby/lib/ruby/1.8/fileutils.rb:526:in `each'
> from E:/Ruby/lib/ruby/1.8/fileutils.rb:526:in `rm_r'
> from E:/Ruby/lib/ruby/1.8/fileutils.rb:550:in `rm_rf'
> from -e:1

It looks like that a recursive version of Chris Morris's
``File.chmod(0644, file)'' hint should do the trick - i.e.

ruby -r fileutils -e "File.chmod(0644,
'directory');FileUtils.rmdir('directory')"

works fine.


/Christoph


Mary Chipman [MSFT]

9/23/2009 4:57:00 PM

0

How to use COM Interop is a different question than the one you
posted. If you're starting from scratch, what I'd recommend is
performing a search to uncover free code that already exists on the
Internet that you can adapt to your purposes. The newsgroups usually
function best for people when they have a specific question that is
fairly limited in scope. When you post a "how do I" question, explain
what you are trying to accomplish. Sometimes people will recommend
solutions that you never thought of, or tell you about pitfalls in the
approach you are taking, such as, "try to avoid creating database
objects from client code" ;-)

--Mary

On Wed, 23 Sep 2009 10:13:46 -0400, SnapDive
<SnapDive@community.nospam> wrote:

>I need to understand how to use COM+Interop (via Visual Studio Project
>reference to the DAO 3.6 library) to set the autoincrement property.
>
>The Access group might be able to tell me things about access, but
>they would not know anything about calling stuff from .NET.
>
>I am posting here because I need help using .NET to access Access.
>
>Please provide me with some information on this.
>
>
>Thanks.
>
>
>
>
>On Tue, 22 Sep 2009 13:10:56 -0400, "Mary Chipman [MSFT]"
><mchip@online.microsoft.com> wrote:
>
>>You'll get a better range of responses on the Access newsgroups on
>>microsoft.public.access -- this one is devoted to .NET.
>>
>>--Mary
>>
>>On Mon, 21 Sep 2009 16:56:28 -0400, SnapDive
>><SnapDive@community.nospam> wrote:
>>
>>>
>>>I have a Jet database I created with ADOX. I now need to set the
>>>autoincrement property on a column but do not understand how to do
>>>it. I think I need to use DAO for this task but need help, can anyone
>>>show sample?
>>>
>>>Thanks.