windows-pr 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,11 @@
1
+ = 0.6.0 - 5-Nov-2006
2
+ * Added the Windows::Volume module.
3
+
4
+ = 0.5.6 - 22-Oct-2006
5
+ * Modified the memcpy method in Windows::MSVCRT::Buffer to do the right
6
+ thing based on the type of the parameters, as well as automatically
7
+ set the default size to the size of the source being copied.
8
+
1
9
  = 0.5.5 - 11-Oct-2006
2
10
  * Prototype modification for VirtualQuery and VirtualQueryEx in the
3
11
  Windows::Memory module.
@@ -7,6 +7,14 @@ module Windows
7
7
  GMEM_MOVABLE = 0002
8
8
  GMEM_ZEROINIT = 0x0040
9
9
  GPTR = 0x0040
10
+
11
+ MEM_COMMIT = 0x1000
12
+ MEM_RESERVE = 0x2000
13
+ MEM_RESET = 0x80000
14
+ MEM_LARGE_PAGES = 0x20000000
15
+ MEM_PHYSICAL = 0x400000
16
+ MEM_TOP_DOWN = 0x100000
17
+ MEM_WRITE_WATCH = 0x200000
10
18
 
11
19
  GlobalAlloc = Win32API.new('kernel32', 'GlobalAlloc', 'II', 'I')
12
20
  GlobalFlags = Win32API.new('kernel32', 'GlobalFlags', 'I', 'I')
@@ -11,9 +11,30 @@ module Windows
11
11
  Memmove = Win32API.new('msvcrt', 'memmove', 'PPL', 'P')
12
12
  Memset = Win32API.new('msvcrt', 'memset', 'PLL', 'L')
13
13
  Swab = Win32API.new('msvcrt', '_swab', 'PPI', 'V')
14
+
15
+ MemcpyPLL = Win32API.new('msvcrt', 'memcpy', 'PLL', 'P')
16
+ MemcpyLPL = Win32API.new('msvcrt', 'memcpy', 'LPL', 'P')
17
+ MemcpyLLL = Win32API.new('msvcrt', 'memcpy', 'LLL', 'P')
18
+ MemcpyPPL = Win32API.new('msvcrt', 'memcpy', 'PPL', 'P')
14
19
 
15
- def memcpy(dest, src, size)
16
- Memcpy.call(dest, src, size)
20
+ # Wrapper for the memcpy() function. Both the +dest+ and +src+ can
21
+ # be either a string or a memory address. If +size+ is omitted, it
22
+ # defaults to the length of +src+.
23
+ #
24
+ def memcpy(dest, src, size = src.length)
25
+ if dest.is_a?(Integer)
26
+ if src.is_a?(String)
27
+ MemcpyLPL.call(dest, src, size)
28
+ else
29
+ MemcpyLLL.call(dest, src, size)
30
+ end
31
+ else
32
+ if src.is_a?(String)
33
+ MemcpyPPL.call(dest, src, size)
34
+ else
35
+ MemcpyPLL.call(dest, src, size)
36
+ end
37
+ end
17
38
  end
18
39
 
19
40
  def memccpy(dest, src, char, count)
@@ -0,0 +1,91 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Volume
5
+ DRIVE_UNKNOWN = 0
6
+ DRIVE_NO_ROOT_DIR = 1
7
+ DRIVE_REMOVABLE = 2
8
+ DRIVE_FIXED = 3
9
+ DRIVE_REMOTE = 4
10
+ DRIVE_CDROM = 5
11
+ DRIVE_RAMDISK = 6
12
+
13
+ FindFirstVolume = Win32API.new('kernel32', 'FindFirstVolume', 'PL', 'L')
14
+ FindFirstVolumeMountPoint = Win32API.new('kernel32', 'FindFirstVolumeMountPoint', 'PPL', 'L')
15
+ FindNextVolume = Win32API.new('kernel32', 'FindNextVolume', 'LPL', 'I')
16
+ FindNextVolumeMountPoint = Win32API.new('kernel32', 'FindNextVolumeMountPoint', 'LPL', 'I')
17
+ FindVolumeClose = Win32API.new('kernel32', 'FindVolumeClose', 'L', 'I')
18
+ FindVolumeMountPointClose = Win32API.new('kernel32', 'FindVolumeMountPointClose', 'L', 'I')
19
+
20
+ GetDriveType = Win32API.new('kernel32', 'GetDriveType', 'P', 'I')
21
+ GetLogicalDrives = Win32API.new('kernel32', 'GetLogicalDrives', 'V', 'L')
22
+ GetLogicalDriveStrings = Win32API.new('kernel32', 'GetLogicalDrives', 'LP', 'L')
23
+ GetVolumeInformation = Win32API.new('kernel32', 'GetVolumeInformation', 'PPLPPPPL', 'I')
24
+ GetVolumeNameForVolumeMountPoint = Win32API.new('kernel32', 'GetVolumeNameForVolumeMountPoint', 'PPL', 'I')
25
+ GetVolumePathName = Win32API.new('kernel32', 'GetVolumePathName', 'PPL', 'I')
26
+ GetVolumePathNamesForVolumeName = Win32API.new('kernel32', 'GetVolumePathNamesForVolumeName', 'PPLL', 'I')
27
+
28
+ SetVolumeLabel = Win32API.new('kernel32', 'SetVolumeLabel', 'PP', 'I')
29
+ SetVolumeMountPoint = Win32API.new('kernel32', 'SetVolumeMountPoint', 'PP', 'I')
30
+
31
+ def FindFirstVolume(name, length=name.size)
32
+ FindFirstVolume.call(name, length)
33
+ end
34
+
35
+ def FindFirstVolumeMountPoint(name, volume, length=volume.size)
36
+ FindFirstVolumeMountPoint.call(name, volume, length)
37
+ end
38
+
39
+ def FindNextVolume(handle, name, length=name.size)
40
+ FindNextVolume.call(handle, name, length) != 0
41
+ end
42
+
43
+ def FindNextVolumeMountPoint(handle, name, length=name.size)
44
+ FindNextVolumeMountPoint.call(handle, name, length) != 0
45
+ end
46
+
47
+ def FindVolumeClose(handle)
48
+ FindVolumeClose.call(handle) != 0
49
+ end
50
+
51
+ def FindVolumeMountPointClose(handle)
52
+ FindVolumeMountPointClose.call(handle) != 0
53
+ end
54
+
55
+ def GetDriveType(path)
56
+ GetDriveType.call(path)
57
+ end
58
+
59
+ def GetLogicalDrives()
60
+ GetLogicalDrives.call()
61
+ end
62
+
63
+ def GetLogicalDriveStrings(length, buffer)
64
+ GetLogicalDriveStrings.call(length, buffer)
65
+ end
66
+
67
+ def GetVolumeInformation(path, v_buf, v_size, serial, length, flags, fs_buf, fs_size)
68
+ GetVolumeInformation.call(path, v_buf, v_size, serial, length, flags, fs_buf, fs_size) != 0
69
+ end
70
+
71
+ def GetVolumeNameForVolumeMountPoint(mount, name, length=name.size)
72
+ GetVolumeNameForVolumeMountPoint.call(mount, name, length) != 0
73
+ end
74
+
75
+ def GetVolumePathName(file, name, length = name.size)
76
+ GetVolumePathName.call(file, name, length) != 0
77
+ end
78
+
79
+ def GetVolumePathNamesForVolumeName(volume, paths, buf_len, return_len)
80
+ GetVolumePathNamesForVolumeName.call(volume, paths, buf_len, return_len) != 0
81
+ end
82
+
83
+ def SetVolumeLabel(label, volume)
84
+ SetVolumeLabel.call(label, volume) != 0
85
+ end
86
+
87
+ def SetVolumeMountPoint(mount, name)
88
+ SetVolumeMountPoint.call(mount, name) != 0
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,32 @@
1
+ #####################################################################
2
+ # tc_volume.rb
3
+ #
4
+ # Test case for the Windows::Volume module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require 'windows/volume'
14
+ require 'test/unit'
15
+
16
+ class Foo
17
+ include Windows::Volume
18
+ end
19
+
20
+ class TC_Windows_Clipboard < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_method_constants
26
+ assert_not_nil(Foo::GetVolumeInformation)
27
+ end
28
+
29
+ def teardown
30
+ @foo = nil
31
+ end
32
+ end
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "windows-pr"
5
- gem.version = "0.5.5"
5
+ gem.version = "0.6.0"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: windows-pr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.5
7
- date: 2006-10-13 00:00:00 -06:00
6
+ version: 0.6.0
7
+ date: 2006-11-17 00:00:00 -07:00
8
8
  summary: Windows functions and constants predefined via Win32API
9
9
  require_paths:
10
10
  - lib
@@ -56,12 +56,12 @@ files:
56
56
  - lib/windows/synchronize.rb
57
57
  - lib/windows/system_info.rb
58
58
  - lib/windows/unicode.rb
59
+ - lib/windows/volume.rb
59
60
  - lib/windows/window.rb
60
61
  - test/ts_all.rb
61
62
  - lib/windows/msvcrt/buffer.rb
62
63
  - lib/windows/msvcrt/file.rb
63
64
  - lib/windows/msvcrt/string.rb
64
- - test/CVS
65
65
  - test/tc_clipboard.rb
66
66
  - test/tc_console.rb
67
67
  - test/tc_error.rb
@@ -77,8 +77,8 @@ files:
77
77
  - test/tc_security.rb
78
78
  - test/tc_synchronize.rb
79
79
  - test/tc_unicode.rb
80
+ - test/tc_volume.rb
80
81
  - CHANGES
81
- - CVS
82
82
  - doc
83
83
  - install.rb
84
84
  - lib