> I have gone as far as to research the code and find that
> loadFile(localPath); returns null.
> Now clearly that is not the case, so with some browser (IE6.0+) and
> networks (XP, NTFS) this is an issue.
> I have gone through the code and though my programming days are long
> over, I find the code to save to be particularly sloppy. I dont know
> whether its the nature of JAVA or the organic development of Tiddly.
> Why cant there be 'SaveMyStuff(Path,Flag)' code? Why all this
> errorchecking and acrobatics that breaks across platforms?
The language is "Javascript"... not "Java". Although they share the
same frist four letters, these are two entirely different languages.
Javascript is an interpreted language, parsed and processed by a
'javascript engine' compiled within each browser. "Java" is compiled
language, processed by an external application (the Sun Java
runtime). Browsers can embed Java via the <applet> tag, and can even
invoke Java-defined APIs from Javascript, but all processing occurs
outside of the browser itself.
Note that, while javascript is *supposed* to conform to the W3C
ECMAScript standards, each browser contains it own implementation of a
'javascript engine', which unfortunately results in some extremely
subtle variations in language interpretation.
As a result, certain functions must be coded to 'sniff' the specific
browser, generally by looking for various text within the browser-
defined "navigator.userAgent" string. However, testing the
'userAgent' string is not absolutely reliable. This is because the
value contained in any given browser implementation can be
deliberately 'spoofed' so that various alternative browsers can report
themselves to be, for example, "IE compatible", when in fact, they are
not truly 100% compatible in all ways (most notably their file I/O
abilities).
Another approach is to forego direct browser detection and wrap
certain functional usage in "try...catch" blocks so that when the most
common usage throws an error, it can fallback to more browser-specific
usage and retry until, hopefully, one of the alternatives succeeds.
In addition to variations in Javascript implementations, there are
also variations in browser/OS handling of path/file naming
conventions. Most notoriously, IE uses Windows-native "\" syntax as a
path separator in URIs, rather than the more generic "/" separator
used throughout the web. Similarly, IE's 'location' field allows
Windows-native filesystem references instead of the W3C standard URI
(file://).
As a result, the code for getLocalPath() and saveFile() isn't
'sloppy'... it's just trying to cope with a great deal of platform and
browser specific variations in filesystem naming conventions and
handling.
> I tried to hack the code so I hardcode my network path to avoid the
> error, but it only breaks things further down.
> var localPath = getLocalPath(originalPath);
> // Load the original file
> var original = ******loadFile(localPath);******** <--- BAD BAD BAD...
Although the problem *might* be in the saveFile() handling, it is most
probably in the getLocalPath() processing. This function starts with
the browser-supplied "document.location" value (which is generally the
same as what is displayed in the browser's location field), and then
attempts to identify and translate that value into a platform-specific
path/file reference.
I suspect that your attempts to hardcode your network path were not
correctly implemented... undoubtedly due to your acknowledge
deficiencies regarding programming in Javascript as well as the
subtleties of cross-browser, cross-platform coding (especially in
regard to file I/O).
In order to identify and implement any solution to your problem, the
first step would be for you to provide more precise details about the
specific environment in which you are operating:
* What browser and version are you using?
* What version of TiddlyWiki are you using?
* How are you mounting your network drives (e.g., are you assigning a
drive letter?)
and, most important:
* What is the *exact* URI that the browser reports?
* What 'hardcoded' path(s) did you actually attempt?
Hopefully, with enough details, it *might* be possible to arrive at a
solution to address your particular environment and filesystem usage,
though there is no guarantee that such a solution (if any) would be
robust enough for general use in other environments.
-e
Eric Shulman
TiddlyTools / ELS Design Studios