Class: ZipTask

Inherits:
CLApp show all
Includes:
FileUtils
Defined in:
lib/rakeutils/ziptask.rb

Overview

Implements programmatic control of the 7Zip application.

Constant Summary collapse

APP_PATH =
"M:/7Zip/7za.exe"

Instance Method Summary collapse

Methods inherited from CLApp

#execute, #normalize_dir_path, #quote_all_values, #quote_value, #rubyize_path, #windowize_path

Constructor Details

#initializeZipTask

Constructor



27
28
29
# File 'lib/rakeutils/ziptask.rb', line 27

def initialize()
    super( APP_PATH )   # Call parent constructor.
end

Instance Method Details

#compress(srcPath, archivePath) ⇒ Object

Compress all files within a directory.

srcPath

Source directory. Path must use forward slashes.

archivePath

Destination file. Path must use forward slashes.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rakeutils/ziptask.rb', line 35

def compress(srcPath, archivePath)
    srcDir = File.dirname( File.expand_path( srcPath ) )
    srcFile = File.basename( srcPath )
    archivePath = File.expand_path( archivePath )
    destDir = File.dirname( archivePath )
    
    puts "srcDir: #{srcDir}"
    puts "srcPath: #{srcPath}"
    puts "destDir: #{destDir}"
    puts "archivePath: #{archivePath}"
    
    if( !File.exists?( destDir ) )          # Create the destination dir if it doesn't exits.
        File.makedirs( destDir, true )
    end
    
    cmdLine = "-tzip u #{archivePath} #{srcPath}"

    curDir = pwd
    cd( srcDir )
        begin
            execute( cmdLine, false )
        rescue
            # do nothing
        end
    cd( curDir )
end