realbasic-nug
[Top] [All Lists]

Unix path

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Unix path
From: Thom McGrath <lists at thezaz dot com>
Date: Sun, 30 Mar 2008 21:22:03 -0400
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Okay, I have not found a good method for finding the unix-style path  
to a folderitem. Shellpath frequently returns the wrong result, and  
the MBS plugin's UnixpathMBS does the same.

So I've written two extension methods. I was wondering if somebody  
could look at them to check for errors. Upon my testing, everything  
appears correct. But I want to make sure I didn't miss anything. The  
first tests if two folder items are equal:

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. And the unixpath:

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
     a = f.parent
     if a = nil or a.exists = false then
       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

I don't need this to work on Windows, as that's nearly useless, but  
Linux should work as well - and I can see this code won't work  
correctly on Linux. Low priority right now.

--
Thom McGrath
The ZAZ Studios
<http://www.thezaz.com/> AIM: thezazstudios


_______________________________________________
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>