src/com/esotericsoftware/scar/Project.java
public void load (String path) throws IOException {
		File file = new File(path);
		if (!file.exists() && !path.endsWith(".yaml")) {
			path += ".yaml";
			file = new File(path);
		}
		if (!file.exists()) throw new IllegalArgumentException("Project not found: " + file.getAbsolutePath());
		if (file.isDirectory()) {
			file = new File(file, "project.yaml");
			if (file.exists())
				load(file.getPath());
			else
				dir = Scar.canonical(path);
			return;
		}
		dir = new File(Scar.canonical(path)).getParent().replace('\\', '/');

		BufferedReader fileReader = new BufferedReader(new FileReader(path));
		try {
			StringBuffer buffer = new StringBuffer(2048);
			while (true) {
				String line = fileReader.readLine();
				if (line == null || line.trim().equals("---")) break;
				buffer.append(line);
				buffer.append('\n');
			}

			YamlReader yamlReader = new YamlReader(new StringReader(buffer.toString())) {
				protected Object readValue (Class type, Class elementType, Class defaultType)
					throws YamlException, ParserException, TokenizerException {
					Object value = super.readValue(type, elementType, defaultType);
					if (value instanceof String) value = ((String)value).replaceAll("\\$dir\\$", dir);
					return value;
				}
			};
			try {
				data = yamlReader.read(HashMap.class);
				yamlReader.close();
			} catch (YamlException ex) {
				throw new IOException("Error reading YAML file: " + new File(path).getAbsolutePath(), ex);
			}
			if (data == null) data = new HashMap();

			buffer.setLength(0);
			while (true) {
				String line = fileReader.readLine();
				if (line == null) break;
				buffer.append(line);
				buffer.append('\n');
			}
			document = buffer.toString();
		} finally {
			fileReader.close();
		}
	}
/** Clears the data in this project and replaces it with the contents of the specified YAML file. The project directory is set
	 * to the directory containing the YAML file.
	 * @param path Path to a YAML project file, or a directory containing a "project.yaml" file. */
Clears the data in this project and replaces it with the contents of the specified YAML file. The project directory is set
to the directory containing the YAML file.
@param path Path to a YAML project file, or a directory containing a "project.yaml" file.
Clears the data in this project and replaces it with the contents of the specified YAML file . The project directory is set to the directory containing the YAML file . @param path Path to a YAML project file or a directory containing a " project . yaml " file .
public void load (String path) throws IOException {
		File file = new File(path);
		if (!file.exists() && !path.endsWith(".yaml")) {
			path += ".yaml";
			file = new File(path);
		}
		if (!file.exists()) throw new IllegalArgumentException("Project not found: " + file.getAbsolutePath());
		if (file.isDirectory()) {
			file = new File(file, "project.yaml");
			if (file.exists())
				load(file.getPath());
			else
				dir = Scar.canonical(path);
			return;
		}
		dir = new File(Scar.canonical(path)).getParent().replace('\\', '/');
		BufferedReader fileReader = new BufferedReader(new FileReader(path));
		try {
			StringBuffer buffer = new StringBuffer(2048);
			while (true) {
				String line = fileReader.readLine();
				if (line == null || line.trim().equals("---")) break;
				buffer.append(line);
				buffer.append('\n');
			}
			YamlReader yamlReader = new YamlReader(new StringReader(buffer.toString())) {
				protected Object readValue (Class type, Class elementType, Class defaultType)
					throws YamlException, ParserException, TokenizerException {
					Object value = super.readValue(type, elementType, defaultType);
					if (value instanceof String) value = ((String)value).replaceAll("\\$dir\\$", dir);
					return value;
				}
			};
			try {
				data = yamlReader.read(HashMap.class);
				yamlReader.close();
			} catch (YamlException ex) {
				throw new IOException("Error reading YAML file: " + new File(path).getAbsolutePath(), ex);
			}
			if (data == null) data = new HashMap();
			buffer.setLength(0);
			while (true) {
				String line = fileReader.readLine();
				if (line == null) break;
				buffer.append(line);
				buffer.append('\n');
			}
			document = buffer.toString();
		} finally {
			fileReader.close();
		}
	}
public void load ( String path ) throws IOException { File file = new File ( path ) ; if ( ! file . exists ( ) && ! path . endsWith ( ".yaml" ) ) { path += ".yaml" ; file = new File ( path ) ; } if ( ! file . exists ( ) ) throw new IllegalArgumentException ( "Project not found: " + file . getAbsolutePath ( ) ) ; if ( file . isDirectory ( ) ) { file = new File ( file , "project.yaml" ) ; if ( file . exists ( ) ) load ( file . getPath ( ) ) ; else dir = Scar . canonical ( path ) ; return ; } dir = new File ( Scar . canonical ( path ) ) . getParent ( ) . replace ( '\\' , '/' ) ; BufferedReader fileReader = new BufferedReader ( new FileReader ( path ) ) ; try { StringBuffer buffer = new StringBuffer ( 2048 ) ; while ( true ) { String line = fileReader . readLine ( ) ; if ( line == null || line . trim ( ) . equals ( "---" ) ) break ; buffer . append ( line ) ; buffer . append ( '\n' ) ; } YamlReader yamlReader = new YamlReader ( new StringReader ( buffer . toString ( ) ) ) { protected Object readValue ( Class type , Class elementType , Class defaultType ) throws YamlException , ParserException , TokenizerException { Object value = super . readValue ( type , elementType , defaultType ) ; if ( value instanceof String ) value = ( ( String ) value ) . replaceAll ( "\\$dir\\$" , dir ) ; return value ; } } ; try { data = yamlReader . read ( HashMap . class ) ; yamlReader . close ( ) ; } catch ( YamlException ex ) { throw new IOException ( "Error reading YAML file: " + new File ( path ) . getAbsolutePath ( ) , ex ) ; } if ( data == null ) data = new HashMap ( ) ; buffer . setLength ( 0 ) ; while ( true ) { String line = fileReader . readLine ( ) ; if ( line == null ) break ; buffer . append ( line ) ; buffer . append ( '\n' ) ; } document = buffer . toString ( ) ; } finally { fileReader . close ( ) ; } }
Clears the data in this project and replaces it with the contents of the specified YAML file.
Clears the data in this project and replaces it with the contents of the specified YAML file .