Bugs: Browse | Submit New | Admin

[#4017] testfile requires tmpdir unconditionally

Date:
2006-04-03 13:53
Priority:
3
Submitted By:
Larry Prall (lgp)
Assigned To:
Akinori MUSHA (knu)
Category:
Files / Dirs / IO
State:
Open
Platform:
 
Summary:
testfile requires tmpdir unconditionally

Detailed description
The 'testfile' module requires the 'tmpdir' module, which in return requires the 'tmpdir' module which is applicable
only to win32 systems.  When running in debug mode this generates an extraneous error:

Exception `LoadError' at /usr/local/lib/ruby/1.8/tmpdir.rb:12 - no such file to load -- Win32API

Suggest modifying the 'testfile' module to require 'tmpdir' only on Windows:

*** tempfile.rb.fixed   Mon Apr  3 09:39:43 2006
--- tempfile.rb Tue May 10 21:46:31 2005
***************
*** 5,11 ****
  #
  
  require 'delegate'
! require 'tmpdir' if RUBY_PLATFORM =~ /mswin/i
  
  # A class for managing temporary files.  This library is written to be
  # thread safe.
--- 5,11 ----
  #
  
  require 'delegate'
! require 'tmpdir'
  
  # A class for managing temporary files.  This library is written to be
  # thread safe.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-05-30 14:44
Sender: Daniel Berger

This ticket can be closed. As of 1.8.6 (and perhaps earlier)
the Windows specific code is wrapped in a begin/rescue clause.

Dan
Date: 2006-04-04 09:41
Sender: Larry Prall

Wrong fix.  Need to modify tmpdir.rb so that it only requires
Win32API on
windows:

*** tmpdir.rb   Tue Apr  4 05:36:21 2006
--- tmpdir.rb.mod       Tue Apr  4 05:32:51 2006
***************
*** 8,14 ****
  
    @@systmpdir = '/tmp'
  
!   if RUBY_PLATFORM =~ /mswin/i
      begin
        require 'Win32API'
        max_pathlen = 260
--- 8,14 ----
  
    @@systmpdir = '/tmp'
  
!  if RUBY_PLATFORM =~ /mswin/i
      begin
        require 'Win32API'
        max_pathlen = 260
***************
*** 24,30 ****
        @@systmpdir = temp if File.directory?(temp) and
File.writable?(temp)
      rescue LoadError
      end
!   end
  
    ##
    # Returns the operating system's temporary file path.
--- 24,31 ----
        @@systmpdir = temp if File.directory?(temp) and
File.writable?(temp)
      rescue LoadError
      end
!  end
! end
  
    ##
    # Returns the operating system's temporary file path.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2007-06-12 01:22zenspider
category_idMisc / Other Standard Library2007-05-29 17:42zenspider