New topic: Folder Items....
<http://forums.realsoftware.com/viewtopic.php?t=33784> Page 1 of 1 [ 12 posts ] Previous topic | Next topic Author Message JustSomeGuy Post subject: Folder Items....Posted: Fri May 14, 2010 11:54 am Joined: Fri May 11, 2007 11:35 am Posts: 821 I am writing a file to disk. The file and the path to the file may not exist but I want to pass back a folder item to where the data should be written. If I say:Code:getPathMethod1(root as folderItem, subdir1 as string, subdir2 as string, fname as string) as string dim f as FolderItem f = root.Child(subdir1).Child(subdir1).Child(fname) return f.ShellPathThis should work even if the root, sub directories and file don't exist? _________________ 6502 Assembler on Steroids Top thx2 Post subject: Re: Folder Items....Posted: Fri May 14, 2010 11:59 am Joined: Sat Nov 24, 2007 11:40 am Posts: 224 If the path is invalid, you get a Nil folderitem. Top npalardy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 12:00 pm Joined: Sat Dec 24, 2005 8:18 pm Posts: 5895 Location: Canada, Alberta, Near Red Deer You may have a hard time if you have a long path that has missing directories as trying to just create the file in directories that dont exist will fail and may raise nil object exceptions _________________ My web site Great White Software RBLibrary.com REALbasic learning Top JustSomeGuy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 12:10 pm Joined: Fri May 11, 2007 11:35 am Posts: 821 I understand that if I use the folderitem and it's not valid the write will fail... but I still need the shellpath. _________________ 6502 Assembler on Steroids Top thx2 Post subject: Re: Folder Items....Posted: Fri May 14, 2010 12:20 pm Joined: Sat Nov 24, 2007 11:40 am Posts: 224 Use a string type Top JustSomeGuy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 2:52 pm Joined: Fri May 11, 2007 11:35 am Posts: 821 ShellPath returns a path where spaces etc. are 'escaped' by "\ " I take that path and store it to the database... At a later time I retrieve the path from the database but the string that is returned is not 'escaped' anymore.... I tried to create a new instance of a folderItem with this string but it fails.... What must I do to the string that contains the path in order to properly format it for a new folder item? _________________ 6502 Assembler on Steroids Top timhare Post subject: Re: Folder Items....Posted: Fri May 14, 2010 2:58 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7751 Location: Portland, OR USA When you store it in the database, you need to escape the escape character. s = replaceall(s, "\", "\\") Otherwise, the db will try to process the escape sequence and remove the escape character. "\\" means "store a single \". Tim Top JustSomeGuy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 3:21 pm Joined: Fri May 11, 2007 11:35 am Posts: 821 wow thats messed up.... Ok before I put it into the database... fname = replaceall(fname, "\", "\\") after I get it out of the database.... fname = replaceall(fname, "\\", "\") f = new FolderItem(fname) I look at the f item in the debugger and AbsolutePath, Name, ShellPath and URLPath are bizarre.... and Exists is False! fname /Users/me/Documents/QViewImages/1014495830\ XXXX\ XXXX\ M\ 19470324/e_1\ CATCH\ BASELINE__CATCH_NEW_\ 20100514\ 081358/Cor\ MP_RAGE\ 20100514\ 083051/1.2.840.113619.2.25.4.488273.1273845672.113.dcm AbsolutPath Macintosh HD:Users:me:Desktop:/Users/me/Documents/QViewImages/1014495830\ XXXX\ XXXX\ M\ 19470324/e_1\ CATCH\ BASELINE__CATCH_NEW_\ 20100514\ 081358/Cor\ MP_RAGE\ 20100514\ 083051/1.2.840.113619.2.25.4.488273.1273845672.113.dcm DisplayName /Users/me/Documents/QViewImages/1014495830\ XXXX\ XXXX\ M\ 19470324/e_1\ CATCH\ BASELINE__CATCH_NEW_\ 20100514\ 081358/Cor\ MP_RAGE\ 20100514\ 083051/1.2.840.113619.2.25.4.488273.1273845672.113.dcm ShellPath /Users/me/Desktop//Users/me/Documents/QViewImages/1014495830\\\ XXXX\\\ XXXX\\\ M\\\ 19470324/e_1\\\ CATCH\\\ BASELINE__CATCH_NEW_\\\ 20100514\\\ 081358/Cor\\\ MP_RAGE\\\ 20100514\\\ 083051/1.2.840.113619.2.25.4.488273.1273845672.113.dcm This makes no sense and I'm unable to delete the file... _________________ 6502 Assembler on Steroids Top timhare Post subject: Re: Folder Items....Posted: Fri May 14, 2010 3:47 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7751 Location: Portland, OR USA Quote:fname = replaceall(fname, "\\", "\") This part is not necessary. The db did that for you. Quote:f = new FolderItem(fname) Did you try f = new FolderItem(fname, FolderItem.PathTypeShell) Top JustSomeGuy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 7:09 pm Joined: Fri May 11, 2007 11:35 am Posts: 821 Nope I needed the 'undo' step .... Wonder if that is going to be the same across database implementations.... Thanks you found the bug. _________________ 6502 Assembler on Steroids Top timhare Post subject: Re: Folder Items....Posted: Fri May 14, 2010 8:13 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 7751 Location: Portland, OR USA JustSomeGuy wrote:Nope I needed the 'undo' step .... Wonder if that is going to be the same across database implementations.... Then it sounds like that wasn't really the problem. Try taking both replaceall's out. It was probably PathTypeShell all along. Top JustSomeGuy Post subject: Re: Folder Items....Posted: Fri May 14, 2010 8:18 pm Joined: Fri May 11, 2007 11:35 am Posts: 821 nope. It's necessary. _________________ 6502 Assembler on Steroids Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 12 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]
