//
// $Id: XMLSceneRepository.java,v 1.7 2001/08/15 01:08:49 mdb Exp $

package com.threerings.miso.scene.xml;

import java.io.IOException;
import java.util.ArrayList;

import com.samskivert.util.Config;
import com.threerings.miso.Log;
import com.threerings.miso.scene.MisoScene;
import com.threerings.miso.tile.TileManager;

/**
 * The <code>XMLFileSceneRepository</code> provides a mechanism for
 * reading scenes from and writing scenes to XML files.  These files will
 * comprise the template scene files from which actual runtime game scenes
 * will be constructed.
 */
public class XMLFileSceneRepository
{
    /**
     * Initialize the XMLFileSceneRepository with the given config and
     * tile manager objects.
     *
     * @param config the config object.
     * @param tilemgr the tile manager object.
     */
    public void init (Config config, TileManager tilemgr)
    {
        // keep these for later
        _config = config;
        _tilemgr = tilemgr;

	// get path-related information
	_sep = System.getProperty("file.separator", "/");
	_root = System.getProperty("root", "");
        _sceneRoot = _config.getValue(CFG_SROOT, DEF_SROOT);

	// create the parser and writer objects
        _parser = new XMLSceneParser(_tilemgr);
        _writer = new XMLSceneWriter();
    }

    /**
     * Return the path to the scene root directory.
     */
    public String getScenePath ()
    {
	return _root + _sep + _sceneRoot + _sep;
    }

    /**
     * Loads and returns a miso scene object for the scene described in
     * the specified XML file. The filename should be relative to the
     * scene root directory.
     *
     * @param fname the full pathname to the file.
     * @return the scene object.
     */
    public MisoScene loadScene (String fname) throws IOException
    {
	String path = getScenePath() + fname;
	Log.info("Loading scene [path=" + path + "].");

        return _parser.loadScene(path);
    }

    /**
     * Writes a scene to the specified file in the scene root
     * directory in XML format.  The filename should be relative to
     * the scene root directory.
     *
     * @param scene the scene to save.
     * @param fname the file to write the scene to.
     */
    public void saveScene (MisoScene scene, String fname) throws IOException
    {
	String path = getScenePath() + fname;
	Log.info("Saving scene [path=" + path + "].");

        _writer.saveScene(scene, path);
    }

    /** The config object. */
    protected Config _config;

    /** The tile manager from which the scenes obtain their tiles. */
    protected TileManager _tilemgr;

    /** The main program absolute root directory. */
    protected String _root;

    /** The root scene directory path. */
    protected String _sceneRoot;

    /** The file separator string. */
    protected String _sep;

    /** The parser object for reading scenes from files. */
    protected XMLSceneParser _parser;

    /** The writer object for writing scenes to files. */
    protected XMLSceneWriter _writer;

    /** The config key for the root scene directory. */
    protected static final String CFG_SROOT = "miso.sceneroot";

    /** The default root scene directory path. */
    protected static final String DEF_SROOT = "rsrc/scenes";
}

@@ -36,9 +36,9 @@
 v 1.
-7
+8
  200
@@ -50,15 +50,15 @@
 15 0
-1:08:49
+2:13:36
  mdb
@@ -105,16 +105,37 @@
 e.xml;%0A%0A
+import java.io.File;%0A
 import j
@@ -1025,59 +1025,8 @@
 ion%0A
-%09_sep = System.getProperty(%22file.separator%22, %22/%22);%0A
 %09_ro
@@ -1384,20 +1384,30 @@
 _root + 
-_sep
+File.separator
  + _scen
@@ -1414,20 +1414,30 @@
 eRoot + 
-_sep
+File.separator
 ;%0A    %7D%0A
@@ -2701,32 +2701,32 @@
 ectory path. */%0A
+
     protected St
@@ -2747,74 +2747,8 @@
 t;%0A%0A
-    /** The file separator string. */%0A    protected String _sep;%0A%0A
     

Use File.separator rather than fetching the system property ourself.