jfclere 2004/11/05 08:03:22 Modified: daemon/src/samples SimpleDaemon.java Log: Add a choice to test PR 30177. Revision Changes Path 1.4 +32 -5 jakarta-commons/daemon/src/samples/SimpleDaemon.java Index: SimpleDaemon.java =================================================================== RCS file: /home/cvs/jakarta-commons/daemon/src/samples/SimpleDaemon.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SimpleDaemon.java 5 Nov 2004 12:08:10 -0000 1.3 +++ SimpleDaemon.java 5 Nov 2004 16:03:22 -0000 1.4 @@ -199,7 +199,7 @@ return(this.directory); } - public void log(String name) + public void createFile(String name) throws IOException { OutputStream file=new FileOutputStream(name,true); PrintStream out=new PrintStream(file); @@ -210,6 +210,15 @@ file.close(); } + public void createDir(String name) + throws IOException { + File file = new File(name); + boolean ok = file.mkdirs(); + if(! ok) + throw new IOException("mkdirs for "+name+" failed"); + createFile(name); + } + public void handle(InputStream in, OutputStream os) { PrintStream out=new PrintStream(os); @@ -225,6 +234,7 @@ out.println(" 3) Create a file"); out.println(" 4) Disconnect"); out.println(" 5) Cause a core of the JVM"); + out.println(" 6) Create a directory"); out.print("Your choiche: "); } @@ -260,14 +270,14 @@ } break; - /* Disconnect */ + /* Create a file */ case '3': String name=this.getDirectoryName()+ "/SimpleDaemon."+ this.getConnectionNumber()+ ".tmp"; try { - this.log(name); + this.createFile(name); out.println("File '"+name+"' created"); } catch (IOException e) { e.printStackTrace(out); @@ -278,11 +288,28 @@ case '4': out.println("Disconnecting..."); return; - /* Need a so file ;-) */ + + /* Crash JVM in a native call: It need an so file ;-) */ case '5': System.load("/home/jakarta/X509/Native.so"); toto(); break; + + /* Create a directory (PR 30177 with 1.4.x and 1.5.0 */ + case '6': + String name1=this.getDirectoryName()+ + "/a/b/c/d/e"+ + "/SimpleDaemon."+ + this.getConnectionNumber()+ + ".tmp"; + try { + this.createDir(name1); + out.println("File '"+name1+"' created"); + } catch (IOException e) { + e.printStackTrace(out); + } + break; + /* Discard any carriage return / newline characters */ case '\r':
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]