win32_filetime 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/bin/getdirtimes +78 -0
- data/bin/rolloldtimes +71 -0
- data/lib/win32_filetime/version.rb +1 -1
- metadata +7 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6a332a4717ba9a99e9e8dc2be746ac9a8203d442
         | 
| 4 | 
            +
              data.tar.gz: 2c9d0e6b3b09ae3cc4409edac0b069187fc70a27
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0daf73590535b81b980301789abeb8403c8b2e912fffc1646b03e8fbd336c2d726f28156aafc85458247abb16e0ea0ee693ff76238d4afd956e6fbee32bf61fd
         | 
| 7 | 
            +
              data.tar.gz: 874c3810671a49e11cbe8dfe2ef3968881f2857ef14b03e08a4305f5818ec848b7901cbbb3efa667c45bc7fd7a4fe04d03ebded31070b085ce2e77fd88960489
         | 
    
        data/bin/getdirtimes
    ADDED
    
    | @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby -w
         | 
| 2 | 
            +
            # encoding: GBK
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'win32ft'
         | 
| 5 | 
            +
            require "dirwalk"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            G = {
         | 
| 8 | 
            +
              :autorun => false,
         | 
| 9 | 
            +
              :stdout => STDOUT,
         | 
| 10 | 
            +
              :prprog => true,
         | 
| 11 | 
            +
              :BS => '',
         | 
| 12 | 
            +
              :WS => '',
         | 
| 13 | 
            +
              :auto_fn => false,
         | 
| 14 | 
            +
              }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            trap "SIGINT" do
         | 
| 17 | 
            +
              STDERR.puts "\n\nexit on Ctrl-C.  ids: #{$ids}  ifs: #{$ifs}"
         | 
| 18 | 
            +
              exit(1)
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            if !STDOUT.tty? && STDERR.tty?
         | 
| 22 | 
            +
              G[:prprog] = true
         | 
| 23 | 
            +
              G[:BS] = "\b" * 78
         | 
| 24 | 
            +
              G[:WS] = " " * 78
         | 
| 25 | 
            +
              def tee(txt, both: true)
         | 
| 26 | 
            +
                puts txt
         | 
| 27 | 
            +
                STDERR.print txt if both
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            else
         | 
| 30 | 
            +
              G[:prprog] = false
         | 
| 31 | 
            +
              def tee(txt, both: true)
         | 
| 32 | 
            +
                puts txt
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            def prdi(di)
         | 
| 37 | 
            +
              $ids, $ifs = 0, 0
         | 
| 38 | 
            +
              t00 = t0 = Time.now
         | 
| 39 | 
            +
              Dir.walk('.') do |p, ds, fs|
         | 
| 40 | 
            +
                p.gsub!('/', "\\")
         | 
| 41 | 
            +
                $ids += 1
         | 
| 42 | 
            +
                tc, ta, tm = Win32ft.getfiletime(p)
         | 
| 43 | 
            +
                puts "#{p}\\ #{tc} #{ta} #{tm} 0"
         | 
| 44 | 
            +
                fs.each do |fn|
         | 
| 45 | 
            +
                  fn = File.join(p, fn)
         | 
| 46 | 
            +
                  fn.gsub!('/', "\\")
         | 
| 47 | 
            +
                  $ifs += 1
         | 
| 48 | 
            +
                  tc, ta, tm, sz= Win32ft.getfiletime(fn, getsize: true)
         | 
| 49 | 
            +
                  puts "#{fn} #{tc} #{ta} #{tm} #{sz}"
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
                if G[:prprog]
         | 
| 52 | 
            +
                  ts = Time.now
         | 
| 53 | 
            +
                  if ts - t0 > 0.3
         | 
| 54 | 
            +
                    STDERR.print "#{G[:BS]} Dir: #{di}  ds: #{$ids}  fs: #{$ifs}  time: #{ts - t00}"
         | 
| 55 | 
            +
                    t0 = ts
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
              if G[:prprog]
         | 
| 60 | 
            +
                ts = Time.now
         | 
| 61 | 
            +
                STDERR.puts "#{G[:BS]} Dir: #{di}  ds: #{$ids}  fs: #{$ifs}  time: #{ts - t00}"
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
            end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            def main
         | 
| 66 | 
            +
              if ARGV.include?('-o')
         | 
| 67 | 
            +
                G[:autofn] = true
         | 
| 68 | 
            +
                ARGV.delete('-o')
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
              ARGV.each do |fn|
         | 
| 71 | 
            +
                fn = File.absolute_path(fn)
         | 
| 72 | 
            +
                if File.directory? fn
         | 
| 73 | 
            +
                  Dir.chdir(fn) {prdi(fn)}
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
            end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            main
         | 
    
        data/bin/rolloldtimes
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby -w
         | 
| 2 | 
            +
            # encoding: GBK
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'openssl'
         | 
| 5 | 
            +
            require 'win32ft'
         | 
| 6 | 
            +
            W = Win32ft
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            trap "SIGINT" do
         | 
| 9 | 
            +
              STDERR.puts "exit on Ctrl-C."
         | 
| 10 | 
            +
              exit 1
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            def getmd5(fn)
         | 
| 14 | 
            +
              md5 = OpenSSL::Digest::MD5.new
         | 
| 15 | 
            +
              File.open(fn, 'rb') do |f|
         | 
| 16 | 
            +
                while d = f.read(4096)
         | 
| 17 | 
            +
                  md5.update(d)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              md5.hexdigest
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            def rolloldtime(d1, d2)
         | 
| 24 | 
            +
              fs1 = Dir.chdir(d1) { Dir.glob '*' }
         | 
| 25 | 
            +
              fs2 = Dir.chdir(d2) { Dir.glob '*' }
         | 
| 26 | 
            +
              fs = fs1 & fs2
         | 
| 27 | 
            +
              fs.each do |fn|
         | 
| 28 | 
            +
                f1 = File.join d1,fn
         | 
| 29 | 
            +
                f2 = File.join d2,fn
         | 
| 30 | 
            +
                if File.directory?(f1) && File.directory?(f2)
         | 
| 31 | 
            +
                  rolloldtime(f1, f2)
         | 
| 32 | 
            +
                elsif File.file?(f1) && File.file?(f2)
         | 
| 33 | 
            +
                  begin
         | 
| 34 | 
            +
                    tc1, ta1, tm1, sz1 = W.getfiletime(f1, getsize: true)
         | 
| 35 | 
            +
                    tc2, ta2, tm2, sz2 = W.getfiletime(f2, getsize: true)
         | 
| 36 | 
            +
                    if sz1 == sz2 && (tc1 != tc2 || tm1 != tm2) && File.readable?(f1) && File.readable?(f2)
         | 
| 37 | 
            +
                      next if sz1 > 2**20 * 200
         | 
| 38 | 
            +
                      md1, md2 = getmd5(f1), getmd5(f2)
         | 
| 39 | 
            +
                      if md1 == md2
         | 
| 40 | 
            +
                        tcx = [tc1, tc2].min
         | 
| 41 | 
            +
                        tax = [ta1, ta2].min
         | 
| 42 | 
            +
                        tmx = [tm1, tm2].min
         | 
| 43 | 
            +
                        if [tcx,tmx] != [tc1,tm1]
         | 
| 44 | 
            +
                          W.setfiletime(f1, tcx, tax, tmx)
         | 
| 45 | 
            +
                          puts " <   #{f1}   CT:#{W.ft2st(W.ft2lft(tcx))}   MT:#{W.ft2st(W.ft2lft(tmx))}"
         | 
| 46 | 
            +
                        end
         | 
| 47 | 
            +
                        if [tcx,tmx] != [tc2,tm2]
         | 
| 48 | 
            +
                          W.setfiletime(f2, tcx, tax, tmx)
         | 
| 49 | 
            +
                          puts "   > #{f2}   CT:#{W.ft2st(W.ft2lft(tcx))}   MT:#{W.ft2st(W.ft2lft(tmx))}"
         | 
| 50 | 
            +
                        end
         | 
| 51 | 
            +
                      end
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
                  rescue Exception => e
         | 
| 54 | 
            +
                    STDERR.puts e
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            def main
         | 
| 61 | 
            +
              if ARGV.size != 2
         | 
| 62 | 
            +
                STDERR.puts "Syntax: rolloldtimes.rb  Dir1 Dir2"
         | 
| 63 | 
            +
                exit 1
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
              if !File.directory?(ARGV[0]) || !File.directory?(ARGV[1])
         | 
| 66 | 
            +
                STDERR.puts "Syntax:  Dir1 Dir2  must be directory"
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
              rolloldtime(ARGV[0], ARGV[1])
         | 
| 69 | 
            +
            end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            main
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: win32_filetime
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - windwiny
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013-12- | 
| 11 | 
            +
            date: 2013-12-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -55,7 +55,9 @@ dependencies: | |
| 55 55 | 
             
            description: win32 filetime api
         | 
| 56 56 | 
             
            email:
         | 
| 57 57 | 
             
            - windwiny.ubt@gmail.com
         | 
| 58 | 
            -
            executables: | 
| 58 | 
            +
            executables:
         | 
| 59 | 
            +
            - getdirtimes
         | 
| 60 | 
            +
            - rolloldtimes
         | 
| 59 61 | 
             
            extensions: []
         | 
| 60 62 | 
             
            extra_rdoc_files: []
         | 
| 61 63 | 
             
            files:
         | 
| @@ -64,6 +66,8 @@ files: | |
| 64 66 | 
             
            - LICENSE.txt
         | 
| 65 67 | 
             
            - README.md
         | 
| 66 68 | 
             
            - Rakefile
         | 
| 69 | 
            +
            - bin/getdirtimes
         | 
| 70 | 
            +
            - bin/rolloldtimes
         | 
| 67 71 | 
             
            - lib/win32_filetime.rb
         | 
| 68 72 | 
             
            - lib/win32_filetime/version.rb
         | 
| 69 73 | 
             
            - lib/win32ft.rb
         |