/**
* @cfg {String} debugTarget target to write files debug version to (uncompacted)- must be full path.
*/
- string debugTarget;
+ string targetDebug;
/**
* @cfg {String} tmpDir (optional) where to put the temporary files.
public string out = ""; // if no target is specified - then this will contain the result
- public Packer(string target, string debugTarget)
+ public Packer(string target, string targetDebug = "")
{
this.target = target;
- this.debugTarget = debugTarget;
+ this.targetDebug = targetDebug;
}
this.files.add(f); //?? easier way?
}
}
+ FileOutputStream targetStream = null;
+ FileOutputStream targetDebugStream = null;
public void pack()
{
if (!this.files) {
throw new Packer.ArgumentError("No Files loaded before pack() called");
}
+ if (this.target.length > 0 ) {
+ this.targetStream = File.new_for_path(this.target).replace(null, false,FileCreateFlags.NONE);
+ }
+ if (this.targetDebug.length > 0 ) {
+ this.targetDebugStream = File.new_for_path(this.targetDebug).replace(null, false,FileCreateFlags.NONE);
+ }
this.packAll();
}
}
}
-
+
private void packAll() // do the packing (run from constructor)
{
//this.transOrigFile= bpath + '/../lang.en.js'; // needs better naming...
//File.write(this.transfile, "");
- if (this.target) {
- File.write(this.target, "");
+ if (this.target.length > 0) {
+ this.targetStream.write("");
}
- if (this.debugTarget) {
- File.write(this.debugTarget, "");
- }
- if (this.debugTranslateTarget) {
- File.write(this.debugTarget, "");
+ if (this.debugTarget > 0) {
+ this.targetDebugStream.write("");
}
-
- for(var i=0; i < this.files.length; i++) {
- var file = this.files[i];
+ foreach(var file in this.files) {
- print("reading " +file );
- if (!File.isFile(file)) {
- print("SKIP (is not a file) " + file);
+ print("reading %s\n",file );
+
+ if (FileUtils.test (file, FileTest.EXISTS) && ! FileUtils.test (file, FileTest.IS_DIR)) {
+ print("SKIP (is not a file) %s\n ", file);
continue;
}
// debug Target
- if (this.debugTarget) {
- File.append(this.debugTarget, File.read(file));
+ if (this.debugTargetStream !=null) {
+ string str;
+ FileUtils.get_contents(file,out str);
+ this.debugTarget.write(str);
}
// it's a good idea to check with 0 compression to see if the code can parse!!
- var minfile = this.tmpDir + '/' +file.replace(/\//g, '.');
+ var minfile = this.tmpDir + '/' + file.replace("/", '.');
// let's see if we have a min file already?
// this might happen if tmpDir is set ..
- if (true && File.exists(minfile)) {
+
+ if (true && FileUtils.test (minfile, FileTest.EXISTS)) {
var mt = File.mtime(minfile);
var ot = File.mtime(file);
print("compare : " + mt + "=>" + ot);