OSDN Git Service

タグを打ち忘れていたついでに、html版ドキュメントを追加しました。
[ring-lang-081/ring.git] / docs / build / html / _sources / ringzip.txt
1 .. index:: 
2         single: RingZip; はじめに
3
4 ==============
5 RingZip の用法
6 ==============
7
8 RingZip の用法を学びます。
9
10 .. index:: 
11         pair: RingZip; Zip ファイルの作成
12
13 Zip ファイルの作成
14 ==================
15
16 用例 : 四本のファイルがある myfile.zip を作成します。
17
18 .. code-block:: ring
19
20         load "ziplib.ring"
21         oZip = zip_openfile("myfile.zip",'w')
22         zip_addfile(oZip,"test.c")
23         zip_addfile(oZip,"zip.c")
24         zip_addfile(oZip,"zip.h")
25         zip_addfile(oZip,"miniz.h")
26         zip_close(oZip)
27
28 .. index:: 
29         pair: RingZip; Zip ファイルの展開
30
31 Zip ファイルの展開
32 ==================
33
34 用例 : myfile.zip を myfolder フォルダへ展開します。
35
36 .. code-block:: ring
37
38         load "ziplib.ring"
39         zip_extract_allfiles("myfile.zip","myfolder")
40
41 .. index:: 
42         pair: RingZip; Zip ファイルにあるファイルのリスト表示
43
44 Zip ファイルにあるファイルのリスト表示
45 ======================================
46
47 用例 : myfile.zip にあるファイル名のリストを表示します。
48
49 .. code-block:: ring
50
51         load "ziplib.ring"
52         oZip = zip_openfile("myfile.zip",'r')
53         for x=1 to zip_filescount(oZip)
54                see zip_getfilenamebyindex(oZip,x) + nl
55         next
56         zip_close(oZip)
57
58 .. index:: 
59         pair: RingZip; RingZip クラスの用法
60
61 RingZip クラスの用法
62 ====================
63
64 RingZip ライブラリには二種類のクラスがあります。すなわち、 Zip クラスと ZipEntry クラスです。
65
66 用例①:
67
68 .. code-block:: ring
69
70         load "ziplib.ring"
71
72         new Zip {
73                 setFileName("myfile.zip")
74                 open("w")
75                 newEntry() {
76                         open("test.c")
77                         writefile("test.c")
78                         close()
79                 }
80                 close()
81         }
82
83 用例②:
84
85 .. code-block:: ring
86
87         load "ziplib.ring"
88
89         new Zip {
90                 SetFileName("myfile.zip")
91                 Open("w")
92                 AddFile("test.c")
93                 AddFile("zip.c")
94                 AddFile("zip.h")
95                 AddFile("miniz.h")
96                 Close()
97         }
98
99
100 用例③:
101
102 .. code-block:: ring
103
104         load "ziplib.ring"
105
106         new zip {
107                 SetFileName("myfile.zip")
108                 ExtractAllFiles("myfolder")
109         }
110
111
112 用例④:
113
114 .. code-block:: ring
115
116         load "ziplib.ring"
117
118         new Zip {
119                 SetFileName("myfile.zip")
120                 Open("r")
121                 see FilesCount()
122                 Close()
123         }
124
125
126 用例⑤:
127
128 .. code-block:: ring
129
130         load "ziplib.ring"
131
132         new Zip {
133                 SetFileName("myfile.zip")
134                 Open("r")
135                 for x = 1 to filescount() 
136                         See GetFileNameByIndex(x) + nl
137                 next
138                 Close()
139         }
140
141 .. index:: 
142         pair: RingZip; Zip クラスリファレンス
143
144 Zip クラスリファレンス
145 ======================
146
147 メソッド:
148
149 =========================== ======================================================================
150 メソッド                    説明・実行結果
151 =========================== ======================================================================
152 SetFileName(cName)          Zip ファイル名を指定します。
153 GetFileName()               Zip ファイル名を返します。
154 Open(cMode)                 ファイルを開きます。 cMode = “a”, “w” または “r”
155 Close()                     Zip ファイルを閉じます。
156 AddFile(cFileName)          Zip ファイルへ新しいファイルを追加します。
157 ExtractAllFiles(cFolder)    Zip ファイルにあるファイルを全て展開します。
158 FilesCount()                Zip ファイルにあるファイルの本数を返します。
159 GetFileNameByIndex(nIndex)  ファイルインデックスから Zip ファイルのファイル名を返します。
160 NewEntry()                  新しい ZipEntry オブジェクトを作成します。
161 =========================== ======================================================================
162
163
164 .. index:: 
165         pair: RingZip; ZipEntry クラスリファレンス
166
167 ZipEntry クラスリファレンス
168 ===========================
169
170 メソッド:
171
172 =========================== ======================================================================
173 メソッド                    説明・実行結果
174 =========================== ======================================================================
175 Open(cFileName)             新しいエントリーを開きます。
176 WriteFile(cFileName)        エントリーからファイルへ書き込みます。
177 WriteString(cString)        エントリーから文字列へ書き込みます。
178 Close()                     エントリーを閉じます。
179 =========================== ======================================================================
180
181