From 02cf32d7b7dd6f500f23c8a10fccfca8546f8f77 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 25 Sep 2004 17:17:14 +0000 Subject: [PATCH] savePath() and createPath() plus some misc --- build/windows/make.sh | 2 ++ core/PApplet.java | 40 ++++++++++++++++++++++++---------------- core/todo.txt | 4 ++++ todo.txt | 3 +++ 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/build/windows/make.sh b/build/windows/make.sh index 0d7265dff..e75607f65 100755 --- a/build/windows/make.sh +++ b/build/windows/make.sh @@ -129,6 +129,8 @@ export CLASSPATH perl preproc.pl ../build/windows/work/jikes -d . +D -target 1.1 *.java +# use this from time to time to test 1.1 savviness +#/cygdrive/c/msjdk-4.0/bin/jvc /d . *.java zip -rq ../build/windows/work/lib/core.jar processing #perl make.pl JIKES=../build/windows/work/jikes JDK13 diff --git a/core/PApplet.java b/core/PApplet.java index 8d5b5c9cd..e8f88a3cb 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -1149,7 +1149,7 @@ public class PApplet extends Applet } //File file = new File(folder, "screen-" + nf(frame, 4) + ".tif"); - save(save_location("screen-" + nf(frameCount, 4) + ".tif", true)); + save(savePath("screen-" + nf(frameCount, 4) + ".tif")); //save("screen-" + nf(frame, 4) + ".tif"); } @@ -1185,7 +1185,7 @@ public class PApplet extends Applet // in case the user tries to make subdirs with the filename //new File(file.getParent()).mkdirs(); //save(file.getAbsolutePath()); - save(save_location(prefix + nf(frameCount, count) + suffix, true)); + save(savePath(prefix + nf(frameCount, count) + suffix)); } } @@ -2116,7 +2116,7 @@ public class PApplet extends Applet */ public PrintWriter writer(String filename) { try { - return writer(new FileOutputStream(save_location(filename, true))); + return writer(new FileOutputStream(savePath(filename))); } catch (IOException e) { e.printStackTrace(); @@ -2298,7 +2298,7 @@ public class PApplet extends Applet */ public void saveBytes(String filename, byte buffer[]) { try { - String location = save_location(filename, true); + String location = savePath(filename); FileOutputStream fos = new FileOutputStream(location); saveBytes(fos, buffer); fos.close(); @@ -2314,8 +2314,9 @@ public class PApplet extends Applet */ public void saveBytes(File file, byte buffer[]) { try { - String filename = save_location(file.getAbsolutePath(), false); - FileOutputStream fos = new FileOutputStream(filename); + String filename = file.getAbsolutePath(); + createPath(filename); + FileOutputStream fos = new FileOutputStream(file); saveBytes(fos, buffer); fos.close(); @@ -2344,7 +2345,7 @@ public class PApplet extends Applet public void saveStrings(String filename, String strings[]) { try { - String location = save_location(filename, true); + String location = savePath(filename); FileOutputStream fos = new FileOutputStream(location); saveStrings(fos, strings); fos.close(); @@ -2358,7 +2359,8 @@ public class PApplet extends Applet public void saveStrings(File file, String strings[]) { try { - String location = save_location(file.getAbsolutePath(), false); + String location = file.getAbsolutePath(); + createPath(location); FileOutputStream fos = new FileOutputStream(location); saveStrings(fos, strings); fos.close(); @@ -2378,24 +2380,30 @@ public class PApplet extends Applet writer.flush(); } + // + /** - * figures out the full path for where to save things - * if 'sketch' is true, then the path will be relative to - * the sketch folder. creates in-between folders if they - * don't already exist. + * Figures out the full path for where to save things. + * Can be used by external libraries to save to the sketch folder. */ - protected String save_location(String where, boolean sketch) { - String filename = - sketch ? (folder + File.separator + where) : where; + public String savePath(String where) { + String filename = folder + File.separator + where; + createPath(filename); + return filename; + } + + /** + * Creates in-between folders if they don't already exist. + */ + static public void createPath(String filename) { File file = new File(filename); String parent = file.getParent(); if (parent != null) { File unit = new File(parent); if (!unit.exists()) unit.mkdirs(); } - return filename; } diff --git a/core/todo.txt b/core/todo.txt index 05eed9844..ed7ea2ed4 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -200,6 +200,10 @@ X get library stuff debugged X port arcball and finish up dxf writer X beginCamera() no longer sets an identity matrix +040925 +X make savePath() and createPath() accessible to the outside world +X useful for libraries saving files etc. + _ before graphics engine change, attach jogl stuff? _ massive graphics engine changes _ explicitly state depth()/nodepth() diff --git a/todo.txt b/todo.txt index a292ffc33..4fdba995c 100644 --- a/todo.txt +++ b/todo.txt @@ -116,6 +116,9 @@ sure if related. same for PATH and CLASSPATH. * some virus scanning software, particularly older NAV versions cause the trouble. +_ remove fonts from distribution +_ fix dist.sh for mac, pc, linux + _ be able to link against, but not export, certain parts of lib _ jsyn.jar not needed on export, netscape libs not needed on export _ netscape.javascript not properly working in 1.4