Rev 237 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Copyright (C) 2007 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* Author: Steve Ratcliffe
* Create date: 20-Oct-2007
*/
package test;
import uk.me.parabola.imgfmt.FileSystemParam;
import uk.me.parabola.imgfmt.fs.FileSystem;
import uk.me.parabola.imgfmt.fs.ImgChannel;
import uk.me.parabola.imgfmt.sys.FileImgChannel;
import uk.me.parabola.imgfmt.sys.ImgFS;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
/**
* Combines several files into one .img file.
* Kind of the opposite of ExtractFile.
* @author Steve Ratcliffe
*/
public class ZipFile {
public static void main
(String[] args
) throws IOException {
FileSystemParam params =
new FileSystemParam
();
String file =
"63240001.img";
if (args.
length > 0)
file = args
[0];
FileSystem fs = ImgFS.
createFs(file, params
);
for (int i =
1; i
< args.
length; i++
) {
System.
out.
println("file " + args
[i
]);
String name = args
[i
];
File f =
new File(name
);
FileImgChannel fin =
new FileImgChannel
(name,
"r");
ImgChannel fout = fs.
create(f.
getName().
toUpperCase());
try {
ByteBuffer buf =
ByteBuffer.
allocate(1024);
while (fin.
read(buf
) > 0) {
buf.
flip();
fout.
write(buf
);
buf.
compact();
}
} finally {
fin.
close();
fout.
close();
}
}
fs.
sync();
fs.
close();
}
}