public virtual bool SaveWorkspace(string containerPath) { if (!PopulateMetaData()) { return(false); } //derive the metafile name from the file name of the full path //the isvr container file will reside at the full path, and will contain //a metafile with the same file name containerPath = DecorateFilePathByWorkspaceType(containerPath); string metaFileName = Path.GetFileNameWithoutExtension(containerPath); MetaData.SetFileName(metaFileName); Debug.Log("saving workspace, " + name + " to metaFile, " + metaFileName + " into container, " + containerPath); if (string.IsNullOrEmpty(MetaData.FileName))//oops never named it! { Debug.LogWarning("you try to save an unnamed workspace metadata, illegal!"); return(false); } //this purges the staging root before gathering if (!ISVR_WorkingTree.GatherDependencyFiles(MetaData.Dependencies)) { return(false); } if (!ISVR_MetaDataFile.SaveMetaData(MetaData, MetaData.FileName)) { return(false); } if (!ISVR_ContainerZip.ZipFolder(ISVR_WorkingTree.StagingRootPath, containerPath)) { return(false); } ISVR_WorkingTree.PurgeStagingRootPath(ISVR_WorkingTree.StagingRootPath); ISVR_MetaDataFile.OpenFolder(Path.GetDirectoryName(containerPath)); return(true); }
public virtual bool LoadWorkspace(string pathToISVRContainer) { Debug.Log("loading workspace..." + name); //clear out whatever schmutz is in the staging area ISVR_WorkingTree.PurgeStagingRootPath(ISVR_WorkingTree.StagingRootPath); //make a decorated pathToISVRContainer by adding the workspace's suffix just before the file extension pathToISVRContainer = DecorateFilePathByWorkspaceType(pathToISVRContainer); //TODO this unzips the "ContainerStaging" folder right into the temporary cachePath // which may have been monkeyed around with by Designer Dan between the save //and the load... so this is potentially destructive.. hmm if (!ISVR_ContainerZip.Unzip(pathToISVRContainer, Application.temporaryCachePath)) { return(false); } //the json file (metaData file) is located in the staging root //under the same name as the container (isvr) //LoadMetaData will append the .json extension var metaFileName = Path.GetFileNameWithoutExtension(pathToISVRContainer); var data = ISVR_MetaDataFile.LoadMetaData(metaFileName); if (data == null) { Debug.LogWarning("could not load metafile " + metaFileName + " for workspace of type, " + GetWorkspaceTypeName()); return(false); } MetaData = data; //make a bunch of actors LoadWorkspace(MetaData);//uses the actor records in metadata //then another step to allow every actor and actorcomponent //a chance to fix up PostLoadWorkspace(MetaData);//uses the actor records in metadata ISVR_WorkingTree.PurgeStagingRootPath(ISVR_WorkingTree.StagingRootPath); return(true); }