Platform-specific file path delimiters
Mark Waddingham
mark at livecode.com
Thu Sep 24 05:29:38 EDT 2015
On 2015-09-23 21:02, Richard Gaskin wrote:
> It's nice when it works like that. I started using MC on Mac Classic,
> and I ran into path issues early on because IIRC no such accommodation
> was made for the Mac-specific ":" delimiter. Rather than read the
> docs I wrote to Dr. Raney, who referred me to the docs.
As I said, the fact it worked on Windows is entirely down to the Win32
APIs being lax - not by explicit design:
i.e. Win32 API calls happily treat / the same as \ in many instances -
this was not the case in Mac Classic API calls.
If it had been me doing the Windows port I would have made the attempt
to use such paths on Windows an error -as my personal opinion is that
explicitly delimited strictness is always better than undocumented
laxness in an environment where you intend things to be 'easy to use'.
> So it looks like we're covered: anyone looking for cross-platform
> info can find what they need, and Windows-specific work is still
> supported using Windows-specific path delimiters.
Again, sorry to beat the drum again here - Windows-specific path
delimiters are supported for backwards-compatibility and no more than
that, please avoid using them for new code.
> Why would that be necessary if Windows-specific paths are supported,
> as Mark just described above?
I realize I didn't explain why it is a bad idea to use \ in your paths -
I shall now attempt to do so.
On UNIX systems '\' is nothing special - it can be part of a filename.
This means that LiveCode has to treat it as part of a filename lest you
want strange reports from users of your software when choosing certain
filenames in an open/save dialog causes odd breakage. Now, fortunately,
'/' *is* reserved on all platforms we support - thus this is the path
separator that LiveCode understands.
Now, at the moment, we do not have much if any syntax which directly
allows you to process file paths. However, it is not beyond the realm of
possibility that (at some point) we will add syntax which allows easier
manipulation. e.g.
put the filename of filepath "foo/bar/zee.txt"
put the folder of filepath "foo/bar/zee.txt"
This syntax would be predicated on using '/' uniformly as the path
separator for all platforms. We can't make it work for both '\' and '/'
as then it would mean you would not be able to access some valid paths
on UNIX derived systems. Thus any application which does use the
Windows-specific platform separator on Windows would find that they
would not be able to use any new syntax that might appear in the future
in this regard.
I should perhaps also point out that there are numerous places in the
engine where it computes the leaf of a filepath - these will not work
with '\' separated paths correctly for exactly the same reason.
Warmest Regards,
Mark.
--
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the use-livecode
mailing list