Hi,


-----Original Message-----
From: Robert Klemme [mailto:shortcutter / googlemail.com] 
Sent: Monday, May 14, 2007 2:45 PM
To: ruby-talk ML
Subject: Re: slow file access with mapped drives ?!

/*
Please make sure you post the code you are actually testing - otherwise 
everybody else will have a hard time understanding what's going on let 
alone come up with helpful replies.
*/

i don't want to bother with bad code, but here is the whole thing,
for you to understand what i try to achieve =

----snipp----

require 'yaml'
require 'highline/import'
require 'win32/registry'
require 'find'

config=YAML.load_file("cvs_login.yaml")

cvsuser = ask("Enter CVS User:       ") {|q|
q.default = "#{ENV["USERNAME"]}"
q.echo = true}
cvspass = ask("Enter password:       ") { |q| q.echo = '*' }
puts "\n\n"

config['cvsrepos'].each {|x|
puts "Login CVS Repository >> #{x} ..."
IO.popen("#{config['CVSEXE']} -d
:pserver:#{cvsuser}:#{cvspass}@cvsprod:d:/cvsrepos/#{x} login")
}
puts "Login successful !!"

def filesed!(pattern, replaceString, filename)
  regexPattern = Regexp.compile(pattern)
  tmpFilename = "#{filename}.#{Time.now.usec}"
  tmpFile = File.new(tmpFilename, "w")
    srcFile = File.open(filename)
      srcFile.each_line do |line|
        tmpFile.print line.gsub(regexPattern) {|match|
        replaceString
      }
  end
  tmpFile.close
  srcFile .close
  File.rename(tmpFilename, filename)
end

if config['targetdirs']

  Win32::Registry::HKEY_CURRENT_USER.open('Software\Cvsnt\cvspass') do
|reg|
         @cvsreg =
reg[":pserver:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test"]
  end

  s=config['replaceto1']<<"#{@cvsreg}"<<config['replaceto2']

  config['targetdirs'].each do |dir|
    puts "\n\n"
    Find.find(dir) do |f|
      if f =~ /#{config['targetfilepattern']}/
      puts "... processing "<<f
      filesed!(config['replacefrom'],s,f)
      end
    end
  end
  puts "\n\nDone !!"
  sleep 1
  else
  puts "\n\nDone !!"
    sleep 1
  end

----snipp---


----yaml---

---
CVSEXE: "./cvsnt/cvs.exe"
cvsrepos:
- foo
- foobar
- foobaz
- bla
- ...

# optional stuff following
targetdirs:
- Y:/tempwork
- T:/rubytest
- //wvp10175/c$/SCM_Server

targetfilepattern: Scm\w+\.xml$

replacefrom: "<Passwort>.*</Passwort>"
replaceto1: "<Passwort><![CDATA["
replaceto2: "]></Passwort>"


----yaml----


the filesed method is not by me, found it somewhere, don't remember

Regards, Gilbert