New topic: 

Did GetFolderItem change?

<http://forums.realsoftware.com/viewtopic.php?t=45576>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        rebrandsoftware          Post subject: Did GetFolderItem 
change?Posted: Wed Oct 10, 2012 3:11 pm                         
Joined: Wed Mar 25, 2009 4:30 pm
Posts: 241
Location: Alexandria, VA, USA                Hi Everyone,

I have a backup application that is having some real problems.  Maybe someone 
can help?

When I do the following on a Mac:

f = getFolderItem("Macintosh HD")

I get the following for f: 

Macintosh HD:Users:Mike:Development:[Current App Dir]:Macintosh HD:

So it seems like it's always looking to the app directory first, even though I 
expect getFolderItem("Macintosh HD") to return the "Macintosh HD" root 
directory.

Am I doing something wrong?  I don't remember this happening in previous 
builds?  GetFolderItem("Macintosh HD") always returned the root hard drive.

-Mike   
                             Top                npalardy          Post subject: 
Re: Did GetFolderItem change?Posted: Wed Oct 10, 2012 3:19 pm                   
    Real Software Engineer          
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7469
Location: Canada, Alberta, Near Red Deer                rebrandsoftware 
wrote:Hi Everyone,

I have a backup application that is having some real problems.  Maybe someone 
can help?

When I do the following on a Mac:

f = getFolderItem("Macintosh HD")

I get the following for f: 

Macintosh HD:Users:Mike:Development:[Current App Dir]:Macintosh HD:

So it seems like it's always looking to the app directory first, even though I 
expect getFolderItem("Macintosh HD") to return the "Macintosh HD" root 
directory.

Am I doing something wrong?  I don't remember this happening in previous 
builds?  GetFolderItem("Macintosh HD") always returned the root hard drive.

-Mike

GetFolderItem might not have changed but the OS did
Use the Volume functions to get the boot drive (which is what I assume you're 
trying to do ?)      
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                             Top                rebrandsoftware          Post 
subject: Re: Did GetFolderItem change?Posted: Wed Oct 10, 2012 3:37 pm          
               
Joined: Wed Mar 25, 2009 4:30 pm
Posts: 241
Location: Alexandria, VA, USA                Thanks for the reply.

I'm not necessarily trying to get the boot drive.

Here is what's going on:

1) The user has backed up some files to a LAN directory
2) They select "restore" to copy them back to their local directory
3) They select a folder that they want to restore to (Macintosh 
HD:Users:Mike:Documents:Restore)
4) The files are copied to a temporary location where they are decompressed
5) The decompressed files are then copied to the "Restore" folder that was 
specified by the user
6) The directory structure is kept intact, so there might be a bunch of 
subdirectories under the "Restore" folder

So the spot where I'm running into trouble is #5 and #6.  Before attempting to 
copy any files, I make sure that proper folder structure exists using 
makeDirsFromPath (shown below).

I pass it something like this:

makeDirsFromPath("Macintosh Hard 
Drive:Users:Mike:Documents:Restore:09:file.jpg", true)

What ends up happening is that it creates those directories as subfolders to 
the app directory.  So it would create:

Macintosh Hard Drive:Users:Mike:Development:23:Macintosh Hard 
Drive:Users:Mike:Documents:Restore:09

instead of creating

Macintosh Hard Drive:Users:Mike:Documents:Restore:09

Then, when I try to copy the files from the Lan to the Restore:09 directory, I 
get a nil folderitem because the 09 directory does not exist (it was created 
under the app directory by accident).

This MakeDirsFromPath function used to work great, now I can't rely on it, and 
bunch of my apps use it, not just this backup app.  Any idea if I can modify it 
so that it doesn't always point to subfolders of the app directory?

The "pathTypeAbsolute" are recent additions, I thought it might help but it 
didn't.

Sub MakeDirsFromPath(sPath as string, optional bFile as boolean = false)
  dim a() as string
  dim i as integer
  dim f as FolderItem
  dim delim as string
  dim iEnd as integer
  
  #if TargetWin32 then
  if instr(1, sPath, "\") > 0 then
  delim = "\"
  elseif instr(1, sPath, "/") > 0 then
  delim = "/"
  end if
  #elseif TargetMacOS then
  delim = ":"
  #endif
  
  'if it's a file, don't create a folder from the last item in the path
  a = split(sPath, delim)
  if bFile = true then
  iEnd = ubound(a) - 1
  else
  iEnd = ubound(a)
  end if
  
  f = new FolderItem
  
  for i = 0 to iEnd
  if i = 0 then
  f = GetTrueFolderItem(a(i), folderitem.PathTypeAbsolute)
  else
  f = getTrueFolderItem(f.AbsolutePath + a(i), folderitem.PathTypeAbsolute)
  end if
  if f <> nil then
  MsgBox f.AbsolutePath
  if f.exists = false then
    f.CreateAsFolder
  end if
  end if
  next
  
End Sub
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to