realbasic-nug
[Top] [All Lists]

Re: Unix path

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Unix path
From: Arnaud Nicolet <anic297 at mac dot com>
Date: Mon, 31 Mar 2008 14:54:05 +0200
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <1E1649D9-FA9F-4889-AB76-27EA2079E71D at thezaz dot com>
Le 31 mars 08 à 03:22 (matin), Thom McGrath a écrit:

> Function Equal(Extends Item1 As FolderItem, Item2 As FolderItem) As
> Boolean
>    if item1 = nil or item2 = nil then
>      return false
>    end
>    #if TargetMacOS
>      if item1.name <> item2.name then
>        return false
>      end
>      if item1.macdirid <> item2.macdirid then
>        return false
>      end
>      if item1.macvrefnum <> item2.macvrefnum then
>        return false
>      end
>      return true
>    #else
>      return (item1.absolutepath = item2.absolutepath)
>    #endif
> End Function
>
> Although I'm pretty sure the non-mac code is incorrect, I did not see
> any reliable methods.

I agree: you can have 2 or more mounted drives on Win32 which points  
to the same folder (therefore, files are the same but not their  
absolute paths). I don't know of a reliable way to figure that out.

> Function Unixpath(Extends TheFolder As FolderItem) As String
>    dim dirs(-1) as string
>    dim f,a as folderitem
>    dim path as string
>    f = thefolder
>    if f.equal(volume(0)) then
>      return "/"
>    end
>    dirs.insert 0,f.name
>    do until false = true

Or only "do"

>      a = f.parent
>      if a = nil or a.exists = false then

I think you will never have a folderitem that does not exist by just  
using .parent.

>        exit
>      end
>      dirs.insert 0,a.name
>      f = a
>    loop
>    if thefolder.macvrefnum = volume(0).macvrefnum then
>      dirs.remove 0
>    else
>      dirs.insert 0,"Volumes"
>    end
>    path = join(dirs,"/")
>    path = "/" + path
>    if thefolder.directory then
>      path = path + "/"
>    end
>    return path
> exception
>    return ""
> End Function

It's a great work; I just hope the OS is doing the same as your code  
(and hope the OS won't change the way it handles that).
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


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