Pages: 1
Print
Author Topic: Read only file system?  (Read 5940 times)
gcrews
Member

Posts: 265


« on: September 14, 2010, 12:23:44 PM »

Would Xmetal work if you’re using it to view content from a read only file system such as a cd? I don’t think the preview tab will work because Xmetal creates a HM###.xml and a ditaval file. Is there a way to tell it to generate those files to the temp dir or specified output dir instead?
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: September 14, 2010, 01:06:40 PM »

It might work. The code (inside multipleOutput.mcr inside the Startup folder) that decides where to create the preview files is as follows:

Code:
function getPreviewPath(docPath,fileExt)
{
var fPath = "";
try{
removeTmpPreviewFiles();
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (docPath != "" && docPath.substr(0, 5) != "http:"){
var docPathObject = fso.GetFolder(docPath);
if (docPathObject.attributes & 1)
{ // ActiveDocument.Path is Read-Only, use css folder instead
var dir = getXMDocumentFolder();
fPath = Application.UniqueFileName(dir,"PRV",fileExt);
}
else
fPath = Application.UniqueFileName(docPath,"PRV",fileExt);
}
else {
var dir = getXMDocumentFolder();
fPath = Application.UniqueFileName(dir,"PRV",fileExt);
}
}
catch(e){
}
if (fPath != "") gTmpPrviewFile.push(fPath);
return fPath;
}

If the Windows File System Object tells that code the path is read-only the logic is supposed to save the temp files to the same folder as the CSS file (typically included with the customization). You can check the path that XMetaL is going to try to save to by running this:

Code:
//XMetaL Script Language JScript:
var dir = getPreviewPath(ActiveDocument.Path,".xml");
Application.Alert(dir);
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #2 on: September 14, 2010, 01:26:51 PM »

Looks like there's more involved here than I thought. A quick test on a write protected floppy shows it fails when attempting to write the temporary XML file (and an error is raised). I assume a CD would be similar behavior. Tested with XMetaL Author Enterprise 6.0.1.030 (I think 6.0 might have a slightly different multipleOutput.mcr file than previous versions).

My steps:

1. Save a file to floppy.
2. Write protect the floppy.
3. Switch to Browser Preview and wait for about 5 minutes.
Windows eventually figures out it can't write there, at which point the XMetaL script fails and raises an error like this:

---------------------------
XMetaL Author Enterprise
---------------------------
Could not open a:\HM49A.xml for writing : Permission denied.

Check the directory and file names and try the operation again.
---------------------------
OK   
---------------------------



Probably best that I just escalate this as a feature request at this point (although you are free to go in and modify this behavior in the MCR file you'd be on your own there). Can I ask why you need this feature to put it into context when I make my write-up?
Logged
gcrews
Member

Posts: 265


« Reply #3 on: September 14, 2010, 02:03:59 PM »

Thanks for the help; I have looked at that code before in multipleOutput.mcr. I think that stuff only gets run when you use the preview html in a meeting file.  It looks like that file is created by DitaRenditions.js in DitaRenditionsImpl.prototype.SaveAsHtmlPdf. I think I have my answer to my questions.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #4 on: September 14, 2010, 02:16:10 PM »

Yes sorry. I've re-read your thread and clued into the fact that you're talking about DITA documents. The preview functionality there is very different and not connected to multipleOutput.mcr (that is something we include for use by people creating their own customizations and will run for anything BUT DITA by default).

For DITA when you switch views to Browser Preview the code (which runs the DITA OT) assumes at first that you want to generate output to the same folder as the DITA source files, which in your case (and with my locked floppy) is read only and it will fail. When you switch directly to Browser Preview the default location is assumed.

However, with DITA you also have the option to select Generate Output from the File menu. You can specify an alternative location in "Save output as". If you do that it will work (provided your output location is write permitted).

I'll log this as the real request. If the location is found to be read-only one option would be to prompt the user for an alternate location.
Logged
Pages: 1
Print
Jump to: