From: nobu.nokada@... Date: 2003-03-31T13:28:53+09:00 Subject: Re: Obtaining the Archive Attribute of a File on Windows Systems --Multipart_Mon_Mar_31_13:28:51_2003-1 Content-Type: text/plain; charset=US-ASCII Hi, At Mon, 31 Mar 2003 08:51:58 +0900, DeLynn Berry wrote: > Is it possible to check the archive attribute of Windows files using > Ruby? Or, even better, is it possible to get a list of files that have > active archive bits to then be able to copy or move to a backup > location? Directly, no. Ruby's file system model bases on UNIX's one. Furthermore, MSVCRT maps attributes but hides some bits including the archive bit. Try this with Win32Module --Multipart_Mon_Mar_31_13:28:51_2003-1 Content-Type: text/x-ruby; charset=US-ASCII Content-Disposition: attachment; filename="win32/stat.rb" Content-Transfer-Encoding: 7bit require 'win32/winbase' require 'win32/winnt' require 'win32/winuser' module Win32 class Stat attr_reader :mode, :ctime, :atime, :mtime, :size, :name FindData = "i i2 i2 i2 i2 i2 Z256" def initialize(path) fd = ([0] * 11 << "").pack(FindData) h = FindFirstFileA.call(path.dup, fd) if h == -1 e = GetLastError.call m = Win32.errorprint(e, "").chomp << " - \"#{path}\"" raise Win32APIException.new(m, e) end FindClose.call(h) @mode, ct0, ct1, at0, at1, mt0, mt1, s1, s0, _, _, @name =fd.unpack(FindData) @ctime = (ct1 << 32) + ct0 @atime = (at1 << 32) + at0 @mtime = (mt1 << 32) + mt0 @size = (s1 << 32) + s0 end def readonly? (@mode & FILE_ATTRIBUTE_READONLY) != 0 end def hidden? (@mode & FILE_ATTRIBUTE_HIDDEN) != 0 end def system? (@mode & FILE_ATTRIBUTE_SYSTEM) != 0 end def directory? (@mode & FILE_ATTRIBUTE_DIRECTORY) != 0 end def archive? (@mode & FILE_ATTRIBUTE_ARCHIVE) != 0 end end end --Multipart_Mon_Mar_31_13:28:51_2003-1 Content-Type: text/plain; charset=US-ASCII -- Nobu Nakada --Multipart_Mon_Mar_31_13:28:51_2003-1--