/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/r3113/plugins/CDVDiso/src/mkiso/mkiso.cpp
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/r3113/plugins/CDVDiso/src/mkiso/mkiso.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations) (download)
Tue Sep 7 06:17:51 2010 UTC (10 years, 7 months ago) by william
File size: 3489 byte(s)
create working branch for pcsx2-0.9.7-r3113-debug
1 /* CDVDiso
2 * Copyright (C) 2002-2004 CDVDiso Team
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include "string.h"
24
25 #include "CDVDiso.h"
26
27
28 void Compress(char *filename, int mode)
29 {
30 struct stat buf;
31 u32 lsn;
32 u8 cdbuff[1024*16];
33 char Zfile[256];
34 int ret = 0;
35 isoFile *src;
36 isoFile *dst;
37
38 if (mode == 1)
39 {
40 sprintf(Zfile, "%s.Z2", filename);
41 }
42 else
43 {
44 sprintf(Zfile, "%s.BZ2", filename);
45 }
46
47 if (stat(Zfile, &buf) != -1)
48 {
49 printf("'%s' already exists\n", Zfile);
50 return;
51 /* sprintf(str, "'%s' already exists, overwrite?", Zfile);
52 if (MessageBox(hDlg, str, "Question", MB_YESNO) != IDYES) {
53 return;
54 }*/
55 }
56
57 printf("src %s; dst %s\n", filename, Zfile);
58 src = isoOpen(filename);
59 if (src == NULL) return;
60
61 if (mode == 1)
62 {
63 dst = isoCreate(Zfile, ISOFLAGS_Z2);
64 }
65 else
66 {
67 dst = isoCreate(Zfile, ISOFLAGS_BZ2);
68 }
69 isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
70 if (dst == NULL) return;
71
72 for (lsn = 0; lsn < src->blocks; lsn++)
73 {
74 printf("block %d ", lsn);
75 putchar(13);
76 fflush(stdout);
77 ret = isoReadBlock(src, cdbuff, lsn);
78 if (ret == -1) break;
79 ret = isoWriteBlock(dst, cdbuff, lsn);
80 if (ret == -1) break;
81 }
82 isoClose(src);
83 isoClose(dst);
84
85 if (ret == -1)
86 {
87 printf("Error compressing iso image\n");
88 }
89 else
90 {
91 printf("Iso image compressed OK\n");
92 }
93 }
94
95 void Decompress(char *filename)
96 {
97 struct stat buf;
98 char file[256];
99 u8 cdbuff[10*2352];
100 u32 lsn;
101 isoFile *src;
102 isoFile *dst;
103 int ret = 0;
104
105 src = isoOpen(filename);
106 if (src == NULL) return;
107
108 strcpy(file, filename);
109 if (src->flags & ISOFLAGS_Z)
110 file[strlen(file) - 2] = 0;
111 else if (src->flags & ISOFLAGS_Z2)
112 file[strlen(file) - 3] = 0;
113 else if (src->flags & ISOFLAGS_BZ2)
114 file[strlen(file) - 3] = 0;
115 else
116 {
117 printf("%s is not a compressed image\n", filename);
118 return;
119 }
120
121 if (stat(file, &buf) != -1)
122 {
123 char str[256];
124 sprintf(str, "'%s' already exists", file);
125 isoClose(src);
126 return;
127 }
128
129 dst = isoCreate(file, 0);
130 if (dst == NULL) return;
131 isoSetFormat(dst, src->blockofs, src->blocksize, src->blocks);
132
133 for (lsn = 0; lsn < src->blocks; lsn++)
134 {
135 printf("block %d ", lsn);
136 putchar(13);
137 fflush(stdout);
138 ret = isoReadBlock(src, cdbuff, lsn);
139 if (ret == -1) break;
140 ret = isoWriteBlock(dst, cdbuff, lsn);
141 if (ret == -1) break;
142 }
143
144 isoClose(src);
145 isoClose(dst);
146
147 if (ret == -1)
148 printf("Error decompressing iso image\n");
149 else
150 printf("Iso image decompressed OK\n");
151 }
152
153
154 /*int main(int argc, char *argv[])
155 {
156 if (argc < 3) return 0;
157
158 switch (argv[1][0])
159 {
160 case 'c':
161 Compress(argv[2], 1);
162 break;
163 case 'C':
164 Compress(argv[2], 2);
165 break;
166 case 'd':
167 Decompress(argv[2]);
168 break;
169 default: break;
170 }
171
172 return 0;
173 }*/

  ViewVC Help
Powered by ViewVC 1.1.22