Re: Performance when Checking if File Exists
Re: Performance when Checking if File Exists
- Subject: Re: Performance when Checking if File Exists
- From: Daniel Shockley <email@hidden>
- Date: Fri, 22 Feb 2002 06:40:42 -0800 (PST)
Hi everyone,
I need to post a MAJOR correction. Richard Morton reminded me that
what I thought I had worked on was completely his work, posted on
the applescript-users list. I have a pretty bad memory, and
unfortunately didn't make any notes to myself where I get some
code from. Mea culpa!
There was a nice thread on high-perfomance file-exists handlers,
and Richard was the one posted the one that I incorrectly thought
I had made. I had an earlier version that did use "as alias"
(which I think I figured out by myself), but the script below is
Richard's and uses the check for empty string. That is because, as
he reminded me, empty string would return true, as he wrote below.
I needed to clear that up. Thanks, all, and thanks to Richard for
giving me the chance to post the correction - shows that he's
smart AND nice! :-)
Richard, any idea about the memory-leak issue I've read about when
trying to resolve invalid aliases?
>
I was ready to post this back to macscrpt, but decided to send it
>
to you instead because I wanted to give you the benefit of the
>
doubt. I don't want to embarrass you. We all make mistakes. I
>
would actually appreciate it though if you could post a correction
>
to the list yourself.
>
>
>I do it slightly differently, as well. I think I remember reading
>
>that there can be memory leaks when trying to get invalid alias
>
>attempts, so I stuck in a little bit of code that tells it not to
>
>bother trying "" as alias.
>
>
That's not why the test is there. Passing an empty string into
>
that handler does not get an "invalid alias". It falsely returns
>
'true' because AS coerces an empty string into the path to the
>
calling app or Editor the script is running from.
>
>
>on testPathExists(inputPath)
>
> -- version 1.4
>
> -- Dan Shockley, email@hidden
>
> -- CORRECTION, Richard Morton's
>
> -- gets somewhat slower as nested-depth level goes over 10
>
>nested folders
>
> if inputPath is not equal to "" then try
>
> get alias inputPath as string
>
> return true
>
> end try
>
> return false
>
>end testPathExists
>
>
One thing I find a little, err, curious about this is that it
>
bears more than a passing resemblance to the one I posted to AS
>
Users on 7 Jan of this year, on a thread you had contributed to -
>
"Re: How can i do?... ("exists" handler)".
=====
Daniel A. Shockley
email@hidden
http://www.danshockley.com
http://www.krioni.com
And now for a message from my sponsor... *grin*
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.