src/main/java/de/vandermeer/execs/Gen_RunScripts.java
protected final int initOutputDir(){
		String parent = System.getProperty("user.dir");
		String target = parent + File.separator + this.target;
		File targetDir = new File(target);
		File parentDir = targetDir.getParentFile();

		if(targetDir.exists()){
			//target dir exists, let's see if it is what we want it to be
			if(!targetDir.isDirectory()){
				System.err.println(this.getAppName() + ": target dir <" + target + "> exists but is not a directory, exiting");
				return -1;
			}
			if(!targetDir.canWrite()){
				System.err.println(this.getAppName() + ": target dir <" + target + "> exists but but cannot write into it, exiting");
				return -1;
			}
		}
		else{
			//target dir does not exist, let's see if we can create it the way we need
			if(!parentDir.isDirectory()){
				System.err.println(this.getAppName() + ": target dir parent <" + parent + "> exists but is not a directory, exiting");
				return -1;
			}
			if(!parentDir.canWrite()){
				System.err.println(this.getAppName() + ": target dir parent <" + parent + "> exists but but cannot write into it, exiting");
				return -1;
			}

			if(!targetDir.mkdir()){
				System.err.println(this.getAppName() + ": could not create target dir <" + target + ">, exiting");
				return -1;
			}
		}

		this.outputDir = target;
		return 0;
	}
protected final int initOutputDir(){
		String parent = System.getProperty("user.dir");
		String target = parent + File.separator + this.target;
		File targetDir = new File(target);
		File parentDir = targetDir.getParentFile();

		if(targetDir.exists()){
			//target dir exists, let's see if it is what we want it to be
			if(!targetDir.isDirectory()){
				System.err.println(this.getAppName() + ": target dir <" + target + "> exists but is not a directory, exiting");
				return -1;
			}
			if(!targetDir.canWrite()){
				System.err.println(this.getAppName() + ": target dir <" + target + "> exists but but cannot write into it, exiting");
				return -1;
			}
		}
		else{
			//target dir does not exist, let's see if we can create it the way we need
			if(!parentDir.isDirectory()){
				System.err.println(this.getAppName() + ": target dir parent <" + parent + "> exists but is not a directory, exiting");
				return -1;
			}
			if(!parentDir.canWrite()){
				System.err.println(this.getAppName() + ": target dir parent <" + parent + "> exists but but cannot write into it, exiting");
				return -1;
			}

			if(!targetDir.mkdir()){
				System.err.println(this.getAppName() + ": could not create target dir <" + target + ">, exiting");
				return -1;
			}
		}

		this.outputDir = target;
		return 0;
	}
protected final int initOutputDir ( ) { String parent = System . getProperty ( "user.dir" ) ; String target = parent + File . separator + this . target ; File targetDir = new File ( target ) ; File parentDir = targetDir . getParentFile ( ) ; if ( targetDir . exists ( ) ) { //target dir exists, let's see if it is what we want it to be if ( ! targetDir . isDirectory ( ) ) { System . err . println ( this . getAppName ( ) + ": target dir <" + target + "> exists but is not a directory, exiting" ) ; return - 1 ; } if ( ! targetDir . canWrite ( ) ) { System . err . println ( this . getAppName ( ) + ": target dir <" + target + "> exists but but cannot write into it, exiting" ) ; return - 1 ; } } else { //target dir does not exist, let's see if we can create it the way we need if ( ! parentDir . isDirectory ( ) ) { System . err . println ( this . getAppName ( ) + ": target dir parent <" + parent + "> exists but is not a directory, exiting" ) ; return - 1 ; } if ( ! parentDir . canWrite ( ) ) { System . err . println ( this . getAppName ( ) + ": target dir parent <" + parent + "> exists but but cannot write into it, exiting" ) ; return - 1 ; } if ( ! targetDir . mkdir ( ) ) { System . err . println ( this . getAppName ( ) + ": could not create target dir <" + target + ">, exiting" ) ; return - 1 ; } } this . outputDir = target ; return 0 ; }
Tests and if necessary creates an output directory.
The root path is the current directory as given by the system property "user.dir".
The created output directory has the name of the specified target for the generator.
The method fails if the output directory cannot be created or if it exists and is write protected.
@return 0 on success with configuration loaded, -1 on error with errors printed on standard error
Tests and if necessary creates an output directory . The root path is the current directory as given by the system property user . dir . The created output directory has the name of the specified target for the generator . The method fails if the output directory cannot be created or if it exists and is write protected .