disk operations - mounting images I've created manually via Disk Utility

2014-03-15 Thread Luther Baker
I'm an iOS developer talking a walk on the OSX side and have a question
about programmatically mounting sparse bundles ... or really just any dmg.

My experimental project is to write a little statusbar application to mount
and unmount disk images. I've created a few of these images in my own
Volumes directory as follows:

/Users/me/Volumes/me.sparsebundle

For the time being, I am hard-wiring logic in a menu selection handler to
actually mount these objects.

I've been digging into Disk Arbitration and I've come up with the following:

- (IBAction)mountMe:(id)sender {
DASessionRef sessionRef = DASessionCreate(kCFAllocatorDefault);
CFURLRef volumeURLRef = (__bridge CFURLRef)[NSURL fileURLWithPath:@
/Users/me/Volumes/me.sparsebundle];
DADiskRef diskRef = DADiskCreateFromVolumePath(kCFAllocatorDefault,
sessionRef, volumeURLRef);
CFURLRef mountPath = NULL;
DADiskMountOptions mountOptions = kDADiskMountOptionDefault;
DADiskMountCallback mountCallback = NULL;
void *context = NULL;
DADiskMount(diskRef, mountPath, mountOptions, mountCallback, context);
CFAllocatorDeallocate(kCFAllocatorDefault, diskRef);
CFAllocatorDeallocate(kCFAllocatorDefault, sessionRef);
}

*ANY* suggestions, even tangental (especially around memory management) are
fair game here. I'd appreciate any input as I'm just starting to read about
allocation, etc.

But more to the point, I don't think DADiskCreateFromVolumePath is what I
want. It seems that DADiskRef is NULL when I run this. Clearly, the most
intimidating method in there is DADiskCreateFromIOMedia ... and I'm afraid
that is the one I'm going to have to use.

And, am I really trying to mount a disk as Disk Arbitration understands
it? I'm not yet dealing with things like fstab, etc which I know very
little about -- but should I start digging that way? I did come across a
nice github project http://tommetge.github.io/VolumeManager/ but
unfortunately I can't actually find any methods in there to mount ... only
things like umount or eject. Notably, the open source project does use
'getmntinfo' which leads me to look at the BSD mount man page ... but I
before going there I want to make sure I'm not _supposed_ to do this in
within Disk Arbitration. There is a DADiskCreateFromBSDName which seems
like it might be similar?
Anyway, any thoughts on this? And in general, is this fundamental stuff
covered in exemplary fashion anywhere? Would the OSX Internals books I've
seen dive into this? I'm assuming that if I've encryped my sparsebundle
that I'd be prompted by the OS for my password, which is fine for my first
pass but I'd eventually like to subsume that logic within my app - if for
no other reason than to simply better understand the partition management
frameworks.

Thanks in advance for even 1 brief minute of your time. I'll begin trying
the alternatives mentioned above in Disk Arbitration.
-Luther
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: disk operations - mounting images I've created manually via Disk Utility

2014-03-15 Thread Michael Starke
I might be missing something, but can't you just open the file with 
[[NSWorkspace sharedWorkspace]openURL:fileURL]?

___m i c h a e l  s t a r k e
geschäftsführer
HicknHack Software GmbH
www.hicknhack-software.com

___k o n t a k t
+49 (170) 36 86 1 36
cont...@hicknhack.com

___H i c k n H a c k S o f t w a r e G m b H
geschäftsführer - maik lathan | andreas reischuck | michael starke
bayreuther straße 32
01187 dresden
amtsgericht dresden HRB 30351
sitz - dresden

 On 15.03.2014, at 21:56, Luther Baker lutherba...@gmail.com wrote:
 
 I'm an iOS developer talking a walk on the OSX side and have a question
 about programmatically mounting sparse bundles ... or really just any dmg.
 
 My experimental project is to write a little statusbar application to mount
 and unmount disk images. I've created a few of these images in my own
 Volumes directory as follows:
 
/Users/me/Volumes/me.sparsebundle
 
 For the time being, I am hard-wiring logic in a menu selection handler to
 actually mount these objects.
 
 I've been digging into Disk Arbitration and I've come up with the following:
 
 - (IBAction)mountMe:(id)sender {
DASessionRef sessionRef = DASessionCreate(kCFAllocatorDefault);
CFURLRef volumeURLRef = (__bridge CFURLRef)[NSURL fileURLWithPath:@
 /Users/me/Volumes/me.sparsebundle];
DADiskRef diskRef = DADiskCreateFromVolumePath(kCFAllocatorDefault,
 sessionRef, volumeURLRef);
CFURLRef mountPath = NULL;
DADiskMountOptions mountOptions = kDADiskMountOptionDefault;
DADiskMountCallback mountCallback = NULL;
void *context = NULL;
DADiskMount(diskRef, mountPath, mountOptions, mountCallback, context);
CFAllocatorDeallocate(kCFAllocatorDefault, diskRef);
CFAllocatorDeallocate(kCFAllocatorDefault, sessionRef);
 }
 
 *ANY* suggestions, even tangental (especially around memory management) are
 fair game here. I'd appreciate any input as I'm just starting to read about
 allocation, etc.
 
 But more to the point, I don't think DADiskCreateFromVolumePath is what I
 want. It seems that DADiskRef is NULL when I run this. Clearly, the most
 intimidating method in there is DADiskCreateFromIOMedia ... and I'm afraid
 that is the one I'm going to have to use.
 
 And, am I really trying to mount a disk as Disk Arbitration understands
 it? I'm not yet dealing with things like fstab, etc which I know very
 little about -- but should I start digging that way? I did come across a
 nice github project http://tommetge.github.io/VolumeManager/ but
 unfortunately I can't actually find any methods in there to mount ... only
 things like umount or eject. Notably, the open source project does use
 'getmntinfo' which leads me to look at the BSD mount man page ... but I
 before going there I want to make sure I'm not _supposed_ to do this in
 within Disk Arbitration. There is a DADiskCreateFromBSDName which seems
 like it might be similar?
 Anyway, any thoughts on this? And in general, is this fundamental stuff
 covered in exemplary fashion anywhere? Would the OSX Internals books I've
 seen dive into this? I'm assuming that if I've encryped my sparsebundle
 that I'd be prompted by the OS for my password, which is fine for my first
 pass but I'd eventually like to subsume that logic within my app - if for
 no other reason than to simply better understand the partition management
 frameworks.
 
 Thanks in advance for even 1 brief minute of your time. I'll begin trying
 the alternatives mentioned above in Disk Arbitration.
 -Luther
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/michael.starke%40hicknhack-software.com
 
 This email sent to michael.sta...@hicknhack-software.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Cocoa custom text field backspace handling

2014-03-15 Thread Daniel Santos
You are right. I should be changing the way the NSTextField looks like



On 06 Mar 2014, at 19:59, Quincey Morris quinceymor...@rivergatesoftware.com 
wrote:

 On Mar 6, 2014, at 11:46 , Kyle Sluder k...@ksluder.com wrote:
 
 Hold up.
 
 Aside from the objections you and Mike raised, there’s actually quite a lot 
 more to be alarmed about in the OP’s code:
 
 1. It overrides keyUp instead of keyDown. ‘interpretKeyEvents:’ probably 
 isn’t even legal in keyUp (which may be why it’s beeping).
 
 2. It (apparently) fails to account for the fact that ‘interpretKeyEvents:’ 
 will eventually invoke ‘insertText:’ if the keystroke isn’t an editing 
 function, so an unconditional ‘appendString:’ is likely duplicative.
 
 3. It’s not even remotely clear whether the OP is trying to suppress the 
 delete, re-implement the standard delete behavior, or some odd combination of 
 both.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/daniel.dlds%40gmail.com
 
 This email sent to daniel.d...@gmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com