Re: notification when app is moved

2008-07-18 Thread Uli Kusterer

On 18.07.2008, at 04:31, Mitchell Livingston wrote:
In some small tests I have seen that other apps break when moved  
while opened (testing with TextEdit), so perhaps I should just  
assume it won't move. I guess this is a moot issue then.



 File a bug with Apple. I think it should be possible to move an app  
while it is running. The more people file bugs on an issue, the more  
likely it is that Apple will actually fix them. And this is a Mac.  
Users shouldn'thave to think about geeky things like that, the  
software should just do the right thing.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Mitchell Livingston
I'm actually using UKKQueue in the project (it's a great utility - thanks a 
lot!).

In some small tests I have seen that other apps break when moved while opened 
(testing with TextEdit), so perhaps I should just assume it won't move. I guess 
this is a moot issue then.
 
On Thursday, July 17, 2008, at 05:03PM, "Uli Kusterer" <[EMAIL PROTECTED]> 
wrote:
>On 17.07.2008, at 12:50, Mitchell Livingston wrote:
>> I need to pass the location to a c library and reset the location in  
>> this library when the application is moved, so I need a way to know  
>> when the app is moved.
>
>> How can I call it again if I don't know it moved? Waiting until it  
>> fails is a bit too late in the process. Sure, chances are the app  
>> won't move, but why should it ever fail? Storing it in the library  
>> folder is not a real good option.
>
>
>As someone else said, use a kqueue to detect the app move. I wrote a  
>nice little wrapper class around kqueues for uses like this, find it at
>
>   
>
>Watch your application bundle folder with that, and when it notifies  
>you that you've been moved, you can call into your library, passing  
>whatever NSBundle pathForResource: returns then.
>
>Just be aware that Cocoa itself is kinda stupid about coping with the  
>current app's bundle being moved (different from Carbon, funnily  
>enough). So, while your library might still access the correct  
>folders, the rest of your app may still go down in flames. Come to  
>think of it, I'm not even sure whether NSBundle doesn't cache its  
>location, so you might get the old path back. But I guess since the  
>kqueue tells you where it got moved, you could deduce the path anyway.
>
>Cheers,
>-- Uli Kusterer
>"The Witnesses of TeachText are everywhere..."
>http://www.zathras.de
>
>
>
>
>
>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Charles Srstka

On Jul 17, 2008, at 1:26 PM, Omar Qazi wrote:
Sure. Then just update it every time the Application starts. Or do  
something like


// I  need to access that one file

if (![[NSFileManager defaultFileManager]fileExistsAtPath:savedPath]) {
newPath = [[NSBundle mainBundle]pathForResource:@"Whatever"  
ofType:@"whatever"];

[self savePath:newPath];
}

//Use saved path


Why are you saving your bundle's path across startups? I wouldn't do  
that - just get it from NSBundle whenever you need it.


On Jul 17, 2008, at 4:03 PM, Uli Kusterer wrote:

Just be aware that Cocoa itself is kinda stupid about coping with  
the current app's bundle being moved (different from Carbon, funnily  
enough).


Probably because Carbon is more likely to be using FSRefs internally.  
Yeah, I wouldn't move a Cocoa app while it's running.


Charles
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Uli Kusterer

On 17.07.2008, at 23:13, Jean-Daniel Dupas wrote:
Correct me if I'm wrong, but kqueue will not work if you move a  
folder that contains the applications (and not the app directly).



 You're right, completely forgot about that.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Jean-Daniel Dupas


Le 17 juil. 08 à 23:13, Jean-Daniel Dupas a écrit :



Le 17 juil. 08 à 23:03, Uli Kusterer a écrit :


On 17.07.2008, at 12:50, Mitchell Livingston wrote:
I need to pass the location to a c library and reset the location  
in this library when the application is moved, so I need a way to  
know when the app is moved.


How can I call it again if I don't know it moved? Waiting until it  
fails is a bit too late in the process. Sure, chances are the app  
won't move, but why should it ever fail? Storing it in the library  
folder is not a real good option.



As someone else said, use a kqueue to detect the app move. I wrote  
a nice little wrapper class around kqueues for uses like this, find  
it at




Watch your application bundle folder with that, and when it  
notifies you that you've been moved, you can call into your  
library, passing whatever NSBundle pathForResource: returns then.


Just be aware that Cocoa itself is kinda stupid about coping with  
the current app's bundle being moved (different from Carbon,  
funnily enough). So, while your library might still access the  
correct folders, the rest of your app may still go down in flames.  
Come to think of it, I'm not even sure whether NSBundle doesn't  
cache its location, so you might get the old path back. But I guess  
since the kqueue tells you where it got moved, you could deduce the  
path anyway.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de



Correct me if I'm wrong, but kqueue will not work if you move a  
folder that contains the applications (and not the app directly).


An other way to do it is to get the file path you want to track at  
startup. Convert it into FSRef, and cache this ref. Then resolve the  
path using this FSRef each time you need it.




And now that I think about it. There is really few chance that your  
application path changes while your application is active. So you may  
listen the applicationDidBecomeActive notification and check your  
application path at this time (resolve it using the cached FSRef and  
compare the result against a cached path. If the path are differents,  
update your library).



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Jean-Daniel Dupas


Le 17 juil. 08 à 23:03, Uli Kusterer a écrit :


On 17.07.2008, at 12:50, Mitchell Livingston wrote:
I need to pass the location to a c library and reset the location  
in this library when the application is moved, so I need a way to  
know when the app is moved.


How can I call it again if I don't know it moved? Waiting until it  
fails is a bit too late in the process. Sure, chances are the app  
won't move, but why should it ever fail? Storing it in the library  
folder is not a real good option.



As someone else said, use a kqueue to detect the app move. I wrote a  
nice little wrapper class around kqueues for uses like this, find it  
at




Watch your application bundle folder with that, and when it notifies  
you that you've been moved, you can call into your library, passing  
whatever NSBundle pathForResource: returns then.


Just be aware that Cocoa itself is kinda stupid about coping with  
the current app's bundle being moved (different from Carbon, funnily  
enough). So, while your library might still access the correct  
folders, the rest of your app may still go down in flames. Come to  
think of it, I'm not even sure whether NSBundle doesn't cache its  
location, so you might get the old path back. But I guess since the  
kqueue tells you where it got moved, you could deduce the path anyway.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de



Correct me if I'm wrong, but kqueue will not work if you move a folder  
that contains the applications (and not the app directly).


An other way to do it is to get the file path you want to track at  
startup. Convert it into FSRef, and cache this ref. Then resolve the  
path using this FSRef each time you need it.



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Uli Kusterer

On 17.07.2008, at 12:50, Mitchell Livingston wrote:
I need to pass the location to a c library and reset the location in  
this library when the application is moved, so I need a way to know  
when the app is moved.


How can I call it again if I don't know it moved? Waiting until it  
fails is a bit too late in the process. Sure, chances are the app  
won't move, but why should it ever fail? Storing it in the library  
folder is not a real good option.



As someone else said, use a kqueue to detect the app move. I wrote a  
nice little wrapper class around kqueues for uses like this, find it at




Watch your application bundle folder with that, and when it notifies  
you that you've been moved, you can call into your library, passing  
whatever NSBundle pathForResource: returns then.


Just be aware that Cocoa itself is kinda stupid about coping with the  
current app's bundle being moved (different from Carbon, funnily  
enough). So, while your library might still access the correct  
folders, the rest of your app may still go down in flames. Come to  
think of it, I'm not even sure whether NSBundle doesn't cache its  
location, so you might get the old path back. But I guess since the  
kqueue tells you where it got moved, you could deduce the path anyway.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Omar Qazi


On Jul 17, 2008, at 3:50 AM, Mitchell Livingston wrote:

How can I call it again if I don't know it moved? Waiting until it  
fails is a bit too late in the process. Sure, chances are the app  
won't move, but why should it ever fail? Storing it in the library  
folder is not a real good option.


Sure. Then just update it every time the Application starts. Or do  
something like


// I  need to access that one file

if (![[NSFileManager defaultFileManager]fileExistsAtPath:savedPath]) {
newPath = [[NSBundle mainBundle]pathForResource:@"Whatever"  
ofType:@"whatever"];

[self savePath:newPath];
}

//Use saved path



smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: notification when app is moved

2008-07-17 Thread Charles Srstka

On Jul 17, 2008, at 5:50 AM, Mitchell Livingston wrote:

How can I call it again if I don't know it moved? Waiting until it  
fails is a bit too late in the process. Sure, chances are the app  
won't move, but why should it ever fail? Storing it in the library  
folder is not a real good option.


Just don't store the path, and call NSBundle each time you want the  
path to the resource.


Charles
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Devon Ferns
Why not just call it every time it starts up?  I can't imagine the 
overhead of the API call is very high.


Devon.

Mitchell Livingston wrote:

How can I call it again if I don't know it moved? Waiting until it fails is a 
bit too late in the process. Sure, chances are the app won't move, but why 
should it ever fail? Storing it in the library folder is not a real good option.
 
On Thursday, July 17, 2008, at 12:09AM, "Omar Qazi" <[EMAIL PROTECTED]> wrote:

On Jul 16, 2008, at 8:28 PM, Mitchell Livingston wrote:

But if the app is moved, the string that was previously returned  
from the call is no longer valid.
So... call it again. You can do this whenever the user starts your  
application, or when the call returns an error saying that it can't  
find the file.


You might be worrying about this too much. How often will a user move  
your application? If these files don't change you might even consider  
copying them to the user's library folder the first time your app is  
run.


Omar Qazi
Hello, Galaxy!
1.310.294.1593




___

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:
http://lists.apple.com/mailman/options/cocoa-dev/dferns%40devonferns.com

This email sent to [EMAIL PROTECTED]

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-17 Thread Mitchell Livingston
How can I call it again if I don't know it moved? Waiting until it fails is a 
bit too late in the process. Sure, chances are the app won't move, but why 
should it ever fail? Storing it in the library folder is not a real good option.
 
On Thursday, July 17, 2008, at 12:09AM, "Omar Qazi" <[EMAIL PROTECTED]> wrote:
>
>On Jul 16, 2008, at 8:28 PM, Mitchell Livingston wrote:
>
>> But if the app is moved, the string that was previously returned  
>> from the call is no longer valid.
>
>So... call it again. You can do this whenever the user starts your  
>application, or when the call returns an error saying that it can't  
>find the file.
>
>You might be worrying about this too much. How often will a user move  
>your application? If these files don't change you might even consider  
>copying them to the user's library folder the first time your app is  
>run.
>
>Omar Qazi
>Hello, Galaxy!
>1.310.294.1593
>
>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-16 Thread Michael Ash
On Wed, Jul 16, 2008 at 9:08 PM, Mitchell Livingston <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have code that must know where a folder inside the Resources folder of the
> application is. This location must be updated whenever the app is moved to
> another location. Is there some sort of callback I can register to receive
> for this?

You can really break this into two pieces:

1) Getting notified when your application moves
2) Finding the new location

1 can be accomplished by using kqueue to watch the containing
directory. 2 can be accomplished by keeping an FSRef to your app in
memory, and resolving it to a path on demand. Note that there is going
to be a certain potential for a race condition between getting 1 and
performing 2, so code with caution.

However, this all seems somewhat academic to me. Cocoa quite simply
does not support moving application packages. It doesn't do this kind
of tracking internally, so when you move, suddenly anything that uses
Cocoa calls directly to find paths to internal application resources
will break. To see what I mean, run TextEdit, move it onto the
desktop, and try to open the preferences or about panel. It falls down
rather hard. So, while you may be able to make this piece of code
behave, you won't be able to make the rest of your app behave, which
probably makes the whole exercise pointless.

Mike
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-16 Thread Omar Qazi


On Jul 16, 2008, at 8:28 PM, Mitchell Livingston wrote:

But if the app is moved, the string that was previously returned  
from the call is no longer valid.


So... call it again. You can do this whenever the user starts your  
application, or when the call returns an error saying that it can't  
find the file.


You might be worrying about this too much. How often will a user move  
your application? If these files don't change you might even consider  
copying them to the user's library folder the first time your app is  
run.


Omar Qazi
Hello, Galaxy!
1.310.294.1593



smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: notification when app is moved

2008-07-16 Thread Mitchell Livingston
I need the full path, yes. I know I can get it using NSBundle. But if the app 
is moved, the string that was previously returned from the call is no longer 
valid. I need to pass the location to a c library and reset the location in 
this library when the application is 
movedhttp://www.me.com/my/mail/en/images/spacer.gif, so I need a way to know 
when the app is moved.
 
On Wednesday, July 16, 2008, at 10:34PM, "Omar Qazi" <[EMAIL PROTECTED]> wrote:
>
>On Jul 16, 2008, at 6:08 PM, Mitchell Livingston wrote:
>
>> I have code that must know where a folder inside the Resources  
>> folder of the application is. This location must be updated whenever  
>> the app is moved to another location. Is there some sort of callback  
>> I can register to receive for this?
>
>Huh? Where a folder inside the resources folder of an application is?  
>I'm going to assume you mean the full path of something inside of an  
>Application bundle.
>
>You don't need to get a notification when the app is moved. Instead, I  
>would recommend using NSBundle's pathForResource: ofType: in  
>combination with NSWorkspace's fullPathForApplication:. So whenever  
>you needed the path of that folder, you could do something like this:
>
>
>NSString *pathToApp = [[NSWorkspace  
>sharedWorkspace]fullPathForApplication:@"Whatever Application"];
>NSBundle *appBundle = [[NSBundle alloc]initWithPath:pathToApp];
>NSString *resourcePath = [appBundle  
>pathForResource:@"WhateverResource" ofType:@"Whatever Type"];
>
>Omar Qazi
>Hello, Galaxy!
>1.310.294.1593
>
>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: notification when app is moved

2008-07-16 Thread Omar Qazi


On Jul 16, 2008, at 6:08 PM, Mitchell Livingston wrote:

I have code that must know where a folder inside the Resources  
folder of the application is. This location must be updated whenever  
the app is moved to another location. Is there some sort of callback  
I can register to receive for this?


Sorry I got confused about what you were trying to say, but if you  
want a resource in your OWN application's bundle you can just use


[[NSBundle mainBundle]pathForResource:@"File" ofType:@"txt"];

and skip that thing I said about NSWorkspace.

smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: notification when app is moved

2008-07-16 Thread Omar Qazi


On Jul 16, 2008, at 6:08 PM, Mitchell Livingston wrote:

I have code that must know where a folder inside the Resources  
folder of the application is. This location must be updated whenever  
the app is moved to another location. Is there some sort of callback  
I can register to receive for this?


Huh? Where a folder inside the resources folder of an application is?  
I'm going to assume you mean the full path of something inside of an  
Application bundle.


You don't need to get a notification when the app is moved. Instead, I  
would recommend using NSBundle's pathForResource: ofType: in  
combination with NSWorkspace's fullPathForApplication:. So whenever  
you needed the path of that folder, you could do something like this:



NSString *pathToApp = [[NSWorkspace  
sharedWorkspace]fullPathForApplication:@"Whatever Application"];

NSBundle *appBundle = [[NSBundle alloc]initWithPath:pathToApp];
NSString *resourcePath = [appBundle  
pathForResource:@"WhateverResource" ofType:@"Whatever Type"];


Omar Qazi
Hello, Galaxy!
1.310.294.1593



smime.p7s
Description: S/MIME cryptographic signature
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: notification when app is moved

2008-07-16 Thread Brett Powley
I have code that must know where a folder inside the Resources  
folder of the application is. This location must be updated whenever  
the app is moved to another location. Is there some sort of callback  
I can register to receive for this?





[[NSBundle mainBundle] resourcePath]

will give you the location of the Resources directory for your  
application.  Why do you need to maintain this location separately?


Cheers,
Brett

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


notification when app is moved

2008-07-16 Thread Mitchell Livingston

Hello,

I have code that must know where a folder inside the Resources folder  
of the application is. This location must be updated whenever the app  
is moved to another location. Is there some sort of callback I can  
register to receive for this?


Thanks,
Mitchell Livingston
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]