Changing permissions in windows XP using ruby!

Hi guys,

I am writing an application in ruby ([U]to run in windows XP[/U]) that
does the normal File System stuff like creating/editing/removing files and
directories. at the start it was all good as making files and directories
is pretty easy in ruby and classes File and Dir already have all the
methods you need. but when it comes to removing/moving/unlinking these
files and folders. I get a "permission denied" error... I check the
permissions to the files or folders I created they look like this:

drwx------+ 2 Administ None 0 Sep 27 18:36 dir1
-rwx------+ 1 Administ None 12 Sep 27 18:36 file1.rb

I tried to give permissions to everyone (as I would do in Linux using
chmod 0777 filename) by using the code:

f = File.new(path, "a+")
puts File.chmod(0777,path)

but it doesn't change anything. so I thought maybe the permission bits are
different in windows from linux. anyways I spent too much time on this and
got nowhere. can anybody help me on this?

i wish i could help you, but i cannot

I tried to give permissions to everyone (as I would do in Linux using
chmod 0777 filename) by using the code:

f = File.new(path, "a+")
puts File.chmod(0777,path)

i double-checked this phenomenon on my pc with both ruby-mswin32 and
ruby-cygwin.

with ruby-mswin32, yes, as you wrote, File#chmod seems not to work as we
expect. with ruby-cygwin, it does work well.
unfortunately, the revision of them are different as below...
- my ruby-mswin32 : 1.8.2
- my ruby-cygwin : 1.8.3

i am not sure that this chmod's problem is based on its revision ( 1.8.2
vs 1.8.3 ) or on its build ( mswin32 vs cygwin ).
i hope anyone who is using ruby-cygwin-1.8.2 or earlier would check this
phenomenon and report the result.

i am sorry, this is not going to solve your problem.
but i will keep this in my mind and continue seeking any solution.

q2hdp://void/3d/universe/milky-way-galaxy/orion-arm/sol-solar-system/
3rd-planet/fareast/jp/tky/shigetomi.takuhiko.5618

hi,

i am still get confused. but... maybe...

require 'fileutils'

FileUtils.rm( path )
or
FileUtils.rm_f( path )

... would help you.
it's worth to try. on my pc, they worked as i expected.

let me put the additional information.
FileUtils.chmod( ... ) also did not work. it seems to be same as
File.chmod.

Hi guys,

I am writing an application in ruby ([U]to run in windows XP[/U]) that
does the normal File System stuff like creating/editing/removing files and
directories. at the start it was all good as making files and directories
is pretty easy in ruby and classes File and Dir already have all the
methods you need. but when it comes to removing/moving/unlinking these
files and folders. I get a "permission denied" error... I check the
permissions to the files or folders I created they look like this:

drwx------+ 2 Administ None 0 Sep 27 18:36 dir1
-rwx------+ 1 Administ None 12 Sep 27 18:36 file1.rb

I tried to give permissions to everyone (as I would do in Linux using
chmod 0777 filename) by using the code:

f = File.new(path, "a+")
puts File.chmod(0777,path)

but it doesn't change anything. so I thought maybe the permission bits are
different in windows from linux. anyways I spent too much time on this and
got nowhere. can anybody help me on this?

xnfp://void/3d/universe/milky-way-galaxy/orion-arm/sol-solar-system/
3rd-planet/fareast/jp/tky/shigetomi.takuhiko.5618

I am writing an application in ruby ([U]to run in windows XP[/U]) ...

[snip]

I tried to give permissions to everyone (as I would do in Linux using
chmod 0777 filename) by using the code:

f = File.new(path, "a+")
puts File.chmod(0777,path)

From the documentation for the File class:
[Slim:~] gavinkis% ri File
...[snip]...
      On non-Posix operating systems, there may be only the ability to
      make a file read-only or read-write. In this case, the remaining
      permission bits will be synthesized to resemble typical values. For
      instance, on Windows NT the default permission bits are +0644+,
      which means read/write for owner, read-only for all others. The
      only change that can be made is to make the file read-only, which
      is reported as +0444+.

(Or see it in glorious HTML at File)

ยทยทยท

On Sep 27, 2005, at 1:16 AM, kraf001 wrote:

so my best luck would be using linux! (damn now I have to work in uni)
thanks for replies anyways..

so my best luck would be using linux! (damn now I have to work in uni)
thanks for replies anyways..

maybe.

but, as i wrote, ruby-cygwin worked as i and you expect.
that's the reason why i use both ruby-mswin32 and ruby-cygwin
simultaneously. many of my file-manipulating-script is running with
ruby-cygwin. if your script is free from anything very specific and
depending on windows, i guess that switching to ruby-cygwin is one of
your choice.

best regards, and i hope your luck :slight_smile:

q2hdp://void/3d/universe/milky-way-galaxy/orion-arm/sol-solar-system/
3rd-planet/fareast/jp/tky/shigetomi.takuhiko.5618