On 10/13/06, Carl Graff <cgraff / chatsworth.com> wrote:
> I have a problem delecting a file that has a UNC path. I am using 1.8.4
> on windows and this same thing did work in 1.8.2.
>
> Here is the pertinent excerpt of code:
> =========================================
> puts shp.source;   ==>  //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt
> puts LOCDIR + '/failed_files'   ==>
> //rm-graff-c/c$/ftpxfr//failed_files
> cp(shp.source, LOCDIR + 'failed_files')  ==> this works
> puts File.file?(shp.source)  ==> this returns true
> rm(shp.source)  ==> this fails with:
>
> C:/ruby/lib/ruby/1.8/fileutils.rb:1281:in `unlink':
>    Permission denied - //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt
> (Errno::EACCES)
> =========================================
> I also tried File.delete(...) and several variations. I really doubt
> that the file is open. I do read from earlier in the program using CSV
> but this is in a block and the end of the block (to my knowlege) should
> be automatically closing the file. I could resort to using .new and
> explictily closing the file when CSV reading is done but I more suspect
> that someting has happened between 1.8.2 and 1.8.4 that is the culprit.
>
> Any ideas? Is this a perhaps a known issue that 1.8.5 fixes. I can with
> a little effort try on unix but I am not sure how to form the equivelent
> UNC pathname in unix to //rm-graff-c/c$/ftpxfr/somefile2454018103834.txt
> - is the C$ just a windows thing?
>

Are you sure you really have the permissions you need to delete that file?
It's working fine for me on 1.8.4 between two Windows XP systems.

irb(main):004:0> file_path = "//10.1.2.3/c$/test.txt"
=> "//10.1.2.3/c$/test.txt"
irb(main):005:0> File.exist?(file_path)
=> true
irb(main):006:0> File.delete(file_path)
=> 1
irb(main):007:0> File.exist?(file_path)
=> false
irb(main):008:0>

I also tried it with escaped backslashes: "\\\\10.1.2.3.\\c$\\test.txt"
..and it worked as well.