win32-file 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.1 - 9-Feb-2009
2
+ * Fixed a bug in the custom File.directory? method with regards to
3
+ non-existent directories.
4
+
1
5
  == 0.6.0 - 14-Nov-2008
2
6
  * Converted methods to use wide character handling.
3
7
  * Added working implementations for the File.readlink, File.symlink and
data/lib/win32/file.rb CHANGED
@@ -19,7 +19,7 @@ class File
19
19
  extend Windows::Handle
20
20
 
21
21
  # The version of the win32-file library
22
- WIN32_FILE_VERSION = '0.6.0'
22
+ WIN32_FILE_VERSION = '0.6.1'
23
23
 
24
24
  # Abbreviated attribute constants for convenience
25
25
 
@@ -455,7 +455,8 @@ class File
455
455
  #
456
456
  def directory?(file)
457
457
  file = multi_to_wide(file)
458
- GetFileAttributesW(file) & FILE_ATTRIBUTE_DIRECTORY > 0
458
+ attributes = GetFileAttributesW(file)
459
+ (attributes != -1) && (attributes & FILE_ATTRIBUTE_DIRECTORY > 0)
459
460
  end
460
461
 
461
462
  # Returns all components of the filename given in +filename+ except the
@@ -1160,4 +1161,69 @@ class File
1160
1161
  alias :set_attr :set_attributes
1161
1162
  alias :unset_attr :remove_attributes
1162
1163
  end
1164
+
1165
+ private
1166
+
1167
+ # Get the owner of a given file by name.
1168
+ #
1169
+ def get_owner(file)
1170
+ handle = CreateFile(
1171
+ file,
1172
+ GENERIC_READ,
1173
+ FILE_SHARE_READ,
1174
+ 0,
1175
+ OPEN_EXISTING,
1176
+ 0,
1177
+ 0
1178
+ )
1179
+
1180
+ if handle == INVALID_HANDLE_VALUE
1181
+ raise ArgumentError, get_last_error
1182
+ end
1183
+
1184
+ sid = 0.chr * 28
1185
+ sid_ptr = [0].pack('L')
1186
+
1187
+ begin
1188
+ rv = GetSecurityInfo(
1189
+ handle,
1190
+ SE_FILE_OBJECT,
1191
+ OWNER_SECURITY_INFORMATION,
1192
+ sid_ptr,
1193
+ nil,
1194
+ nil,
1195
+ nil,
1196
+ nil
1197
+ )
1198
+
1199
+ if rv != 0
1200
+ raise get_last_error
1201
+ end
1202
+
1203
+ name_buf = 0.chr * 80
1204
+ name_cch = [name_buf.size].pack('L')
1205
+
1206
+ domain_buf = 0.chr * 80
1207
+ domain_cch = [domain_buf.size].pack('L')
1208
+ sid_name = 0.chr * 4
1209
+
1210
+ bool = LookupAccountSid(
1211
+ nil,
1212
+ sid_ptr.unpack('L').first,
1213
+ name_buf,
1214
+ name_cch,
1215
+ domain_buf,
1216
+ domain_cch,
1217
+ sid_name
1218
+ )
1219
+
1220
+ unless bool
1221
+ raise get_last_error
1222
+ end
1223
+ ensure
1224
+ CloseHandle(handle)
1225
+ end
1226
+
1227
+ name_buf.strip
1228
+ end
1163
1229
  end
@@ -26,7 +26,13 @@ class TC_Win32_File_Attributes < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def test_version
29
- assert_equal('0.6.0', File::WIN32_FILE_VERSION)
29
+ assert_equal('0.6.1', File::WIN32_FILE_VERSION)
30
+ end
31
+
32
+ def test_is_directory
33
+ assert_true(File.directory?(Dir.pwd))
34
+ assert_false(File.directory?(@@file))
35
+ assert_false(File.directory?('C:/aaabbbccc'))
30
36
  end
31
37
 
32
38
  def test_temporary
data/win32-file.gemspec CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "win32-file"
5
- gem.version = "0.6.0"
5
+ gem.version = "0.6.1"
6
6
  gem.authors = ["Daniel J. Berger", "Park Heesob"]
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
@@ -17,12 +17,12 @@ spec = Gem::Specification.new do |gem|
17
17
  gem.extra_rdoc_files = ["README", "CHANGES"]
18
18
  gem.add_dependency("win32-api", ">= 1.2.1")
19
19
  gem.add_dependency("win32-file-stat", ">= 1.3.2")
20
- gem.add_dependency("test-unit", ">= 2.0.0")
21
- gem.add_dependency("windows-pr", ">= 0.9.6")
20
+ gem.add_dependency("test-unit", ">= 2.0.1")
21
+ gem.add_dependency("windows-pr", ">= 0.9.7")
22
22
  gem.rubyforge_project = "win32utils"
23
23
  end
24
24
 
25
25
  if $0 == __FILE__
26
- Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.3
26
+ Gem.manage_gems if Gem::RubyGemsVersion.to_f < 1.0
27
27
  Gem::Builder.new(spec).build
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-11-14 00:00:00 -07:00
13
+ date: 2009-02-09 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -41,7 +41,7 @@ dependencies:
41
41
  requirements:
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 2.0.0
44
+ version: 2.0.1
45
45
  version:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: windows-pr
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.6
54
+ version: 0.9.7
55
55
  version:
56
56
  description: Extra or redefined methods for the File class on Windows.
57
57
  email: djberg96@gmail.com