realbasic-nug
[Top] [All Lists]

Re: When is it safe to read a folderItem

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: When is it safe to read a folderItem
From: Charles Yeomans <charles at declareSub dot com>
Date: Sun, 31 Jul 2005 10:55:45 -0400
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20050729170018 dot 92C81BF1836 at lists dot realsoftware dot com> <FFA10C0B-009E-11DA-8428-003065A8D4B0 at ilike dot co dot nz>

On Jul 29, 2005, at 10:09 PM, Kevin Bracey wrote:

We all know users like to move, and delete there own files. I'm storing GetSaveInfo of the last opened file and would like to open it when my app re-opens, so they can continue working on the last document. I also want to maintain an Open Recent file menu. There seems to be so many things to check, before reading a file. What is the best method?

myFolderItem = GetFolderItem( savedGetSaveInfo )

    If myFolderItem <> Nil Then
      If myFolderItem.Exists Then
        If myFolderItem.IsReadable Then
          If myFolderItem.Length <> 0 then
If myFolderItem.LastErrorCode <> 101 AND myFolderItem.LastErrorCode <> 102 Then // File Not Found or Access Denied
              holdImReadable = True
            End
          End
        End
      End
    End



It's not clear to me precisely what you want to check. For building the recent items menu, it is enough to check that the alias returns a non-nil, existing FolderItem. You can worry about readability only when the user attempts to read the file, at which point you can simply attempt to get a BinaryStream or TextInputStream. If you can, then the file is probably readable.

I wrote an article for RBD on building a recent items menu for issue 2.1. You might consider purchasing that issue from the RBD web site <http://www.rbdeveloper.com/>.


--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>