Real Software Forums
http://forums.realsoftware.com/

Saving files on Network volume
http://forums.realsoftware.com/viewtopic.php?f=2&t=46687
Page 1 of 1

Author:  lenpartico [ Thu Jan 24, 2013 8:42 pm ]
Post subject:  Saving files on Network volume

Hello,

I have two computers connected via an Ethernet Switch - "Mac Mini 183" and "Mac Mini 166"

myApp is a program I created in RS.

When I am working on myApp on "Mac Mini 183" I would like to save the document on "Mac Mini 166" in a folder named "MacMini166 Shared" in "Mac Mini 166" Public folder.

How do I do that?

Thanks.

Lennox

Author:  ktekinay [ Thu Jan 24, 2013 10:26 pm ]
Post subject:  Re: Saving files on Network volume

If you want your app to mount the volume, that's a different discussion. If it's already mounted, use:
dim f as FolderItem = GetFolderItem( "Public:MacMini166 Shared:", FolderItem.PathTypeAbsolute )

But hard-coding a path is a bad idea. Better to have the user select the folder once, then store the string returned from "GetSaveInfo" somewhere like a prefs file. On the next run, you can recreate the destination from that string.

If you download the MacOSLib package, there is true alias handling code and plist code within that will not only let you save an alias, but will mount the volume for you when you try to resolve it.

https://github.com/macoslib/macoslib

Author:  lenpartico [ Thu Jan 24, 2013 10:38 pm ]
Post subject:  Re: Saving files on Network volume

Thanks Kem,
Yes, your suggestion is what I think I really wanted.
I will try it.
Lennox

Author:  lenpartico [ Fri Jan 25, 2013 7:33 am ]
Post subject:  Re: Saving files on Network volume

ktekinay wrote:
If you want your app to mount the volume, that's a different discussion. If it's already mounted, use:
dim f as FolderItem = GetFolderItem( "Public:MacMini166 Shared:", FolderItem.PathTypeAbsolute )

But hard-coding a path is a bad idea. Better to have the user select the folder once, then store the string returned from "GetSaveInfo" somewhere like a prefs file. On the next run, you can recreate the destination from that string.

If you download the MacOSLib package, there is true alias handling code and plist code within that will not only let you save an alias, but will mount the volume for you when you try to resolve it.

https://github.com/macoslib/macoslib



Hi Kem,

I already have macoslib, and I have downloaded the latest version from the above link.

Could you tell me where that 'true alias handling code and plist code" is located?

Lennox

Author:  ktekinay [ Fri Jan 25, 2013 3:23 pm ]
Post subject:  Re: Saving files on Network volume

In the macoslib folder, look for the FileManager module and the FSAliasRecord within. For PLists, there are a number of ways, but the easiest is to use MacPListBrowser in the Additional Modules. EXCEPT, in testing, I found there is problem when retrieving FolderItems that no longer exist, so I will be posting an update to MacOSLib later. Once I do, you can do something like this:
dim f as FolderItem = <your network volume>
dim prefs as new MacPListBrowser
prefs.Child( "save folder" ) = f
if not prefs.SaveToFile( prefFile ) then
// Do something with the error
end if

Later:
dim prefs as MacPListBrowser = MacPListBrowser.CreateFromPListFile( prefFile )
dim pSaveFolder as MacPListBrowser = prefs.Child( "save folder" )
dim f as FolderItem = pSaveFolder.VariantValue
if f is nil or not f.Exists then
dim info as string = pSaveFolder.StringValue // This will be in the update
f = FileManager.GetFolderItemFromAliasData( info, nil, FileManager.kFSResolveAliasTryFileIDFirst )
end if
if f is nil or not f.Exists then
// Something has gone wrong
end if

Author:  lenpartico [ Fri Jan 25, 2013 5:22 pm ]
Post subject:  Re: Saving files on Network volume

ktekinay wrote:
In the macoslib folder, look for the FileManager module and the FSAliasRecord within. For PLists, there are a number of ways, but the easiest is to use MacPListBrowser in the Additional Modules. EXCEPT, in testing, I found there is problem when retrieving FolderItems that no longer exist, so I will be posting an update to MacOSLib later. Once I do, you can do something like this:
dim f as FolderItem = <your network volume>
dim prefs as new MacPListBrowser
prefs.Child( "save folder" ) = f
if not prefs.SaveToFile( prefFile ) then
// Do something with the error
end if

Later:
dim prefs as MacPListBrowser = MacPListBrowser.CreateFromPListFile( prefFile )
dim pSaveFolder as MacPListBrowser = prefs.Child( "save folder" )
dim f as FolderItem = pSaveFolder.VariantValue
if f is nil or not f.Exists then
dim info as string = pSaveFolder.StringValue // This will be in the update
f = FileManager.GetFolderItemFromAliasData( info, nil, FileManager.kFSResolveAliasTryFileIDFirst )
end if
if f is nil or not f.Exists then
// Something has gone wrong
end if



Thanks Kem,
When you post the update could you PM me.?
Thanks again.

Lennox

Author:  ktekinay [ Fri Jan 25, 2013 11:19 pm ]
Post subject:  Re: Saving files on Network volume

I don't know when that might be, but you can get the changes I just pushed from my repository here:

https://github.com/ktekinay/macoslib

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/