Thread Rating:
  • 521 Vote(s) - 2.91 Average
  • 1
  • 2
  • 3
  • 4
  • 5
圧縮ファイルの作成
01-29-2013, 05:24 PM,
#1
圧縮ファイルの作成
Curl で、圧縮ファイル(ZIPやLZHなど)を作成することは可能ですか?

また、指定したフォルダを圧縮することはできますか?

できるとしたら、それには外部のDLLを利用する必要があるのでしょうか。
01-31-2013, 02:47 PM,
#2
RE: 圧縮ファイルの作成
zipの場合、ZIP32.DLL,ZIP32J.DLLを使えばできます。

簡単なzip圧縮例です。ZIP32.DLLとZIP32J.DLLがwindowsのsystemフォルダにあることが条件です。

Code:
{import * from CURL.LANGUAGE.DLL-INTERFACE}
{define-dll-class public ZIP
  {defaults
      calling-convention = stdcall,
      string-rep = CString
  }
  {constructor public {default}
      {construct-super {SharedLibrary "ZIP32J"}}
  }
  {dll-method public {zip("Zip")
                         hwnd:CPointer = null,
                         command:StringInterface (rep = CString)
                     }:int
  }
}
{value
    {try
        def zip = {ZIP}
        || 圧縮元ファイルパス
        def file-path = "c:\\windows\\temp\\log"
        || 圧縮ファイルパス
        def zip-path = "c:\\window\\temp\\log.zip"
        || 圧縮コマンド
        def rtn = {zip.zip "-r -q " & zip-path & " " & file-path}
        || エラー判定
        {if rtn != 0 then
            {output "Error Code = " & rtn}
        }
     catch e:Exception do
        {output e.message}
    }
}



01-31-2013, 05:42 PM,
#3
RE: 圧縮ファイルの作成
やはり、外部dll が必要ですよね。

SharedLibrary のヘルプを見ると、curl://install/bin など、いくつかのディレクトリを自動で検索してくれるんですね。
Windows の system システムフォルダは、下記のPATH環境変数に入っているから、ということでしょうか。
勉強になりました。ありがとうございます。

Code:
{get-from-host-environment "path"}




05-23-2013, 05:31 PM,
#4
RE: 圧縮ファイルの作成
古いスレッドに返信するのも、どうかと思ったんですが、後の人が見るかもしれないので。

DeflateByteOutputStream で圧縮
InflateByteInputStream  で解凍

が出来ます。

圧縮形式はzlibかgzipですが。。。
05-24-2013, 09:05 AM,
#5
RE: 圧縮ファイルの作成
圧縮API を教えていただき、ありがとうございます。
ただ、私が現在使っている解凍ソフト「+Lacha」では、解凍されませんでした

てっきりZIP形式=gzip と思っていたのですが、実際には異なり、
「+Lhaca」では、gzip、zlib の形式に対応していない、という認識です。

サーバとファイルをやり取りしたりする際に、サイズを小さくするためには有益ですね。

Code:
{import * from CURL.IO.ZSTREAM}
{def cmp-dl =
    {DropdownList
        CompressionFormat.gzip,
        CompressionFormat.zlib
    }
}
{value cmp-dl}
{CommandButton
    label = "圧縮",
    {on Action do
        {if-non-null u = {choose-file} then
            def out = {url u.full-filename & ".zip"}
            def dbos =
                {DeflateByteOutputStream
                    {write-open-byte out},
                    compression-format = cmp-dl.value asa CompressionFormat
                }
            def (bytes:{Array-of byte}, n:int) = {read-bytes-from u}
            {dbos.write bytes}
            {dbos.close}
        }
    }
}
05-24-2013, 05:01 PM,
#6
RE: 圧縮ファイルの作成
試さずに返信してるので、違ってたらすいません。


http://detail.chiebukuro.yahoo.co.jp/qa/...1210471117

gzip=拡張子は"gz"みたいですよ。

上のサイトの情報によると、「+Lhaca」で解凍できるみたいなので、試してみては!?


07-05-2013, 08:04 PM,
#7
RE: 圧縮ファイルの作成
私は、コードを共有するためのおかげでこれをしようとします。

Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('832')