Who's Online
147 user(s) are online (
132 user(s) are browsing
Forums )
Members: 1
Guests: 146
amigait ,
more...
Topic options
View mode
Newest First
File notify question.
Posted on:
2014/2/12 16:33
#1
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
I'm looking at the fs_notify_test.c example, and it does notify about files in sub directory's, but is possible to make it notify about changes in sub directory’s also? And also it be nice if notified about deleting and creating directories.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/16 12:17
#2
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@LiveForIt This is important, the program I'm writing depends on best possible notification service, so if anyone can help. I need to be notified when directory’s are created, when they are deleted, when files are changed or created or replaced. I need to know if there is changes in sub directory’s of directory I'm monitoring.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/16 17:36
#3
Just can't stay away
Joined: 2008/1/6 17:56Last Login
: 2023/4/18 20:37
From Pennsylvania, USA
Group:
Registered Users
@LiveForIt I just did some testing with the waitnotify command. If I wait on a directory, any activity in that directory (files, new sub-directories, deleted directories etc.) causes the wait to end. The waitnotify command at OS4Depot includes the source code which may be of some help.
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450
Re: File notify question.
Posted on:
2014/2/16 18:04
#4
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@xenic Excellent, I have a look. Thanks.
Edited by LiveForIt on 2014/2/17 11:06:38
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/16 21:43
#5
Just can't stay away
Joined: 2006/12/1 18:01Last Login
: Yesterday 23:00
From Copenhagen, Denmark
Group:
Registered Users
@LiveForIt Don't forget that depending on the filesystem (I believe), it may differ whether activity in a subdir of a subdir will be visible/notified "two layers above". You should make sure you test the features you need in a situation with multiple layers of subdirectories. Best regards, Niels
Re: File notify question.
Posted on:
2014/2/16 22:10
#6
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@nbache
Quote:
Don't forget that depending on the filesystem (I believe), it may differ whether activity in a subdir of a subdir will be visible/notified "two layers above".If ADO_DOSMethodOnly is set to TRUE notifications will work the same no matter what the underlying filesystem is (see autodoc for more details).
Re: File notify question.
Posted on:
2014/2/17 7:23
#7
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@xenic The example does not inform me what has changed, so it can't be used, but thanks anyway.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/17 10:20
#8
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
This is my test code for NotifyMessage, but NotifyMessage does not give any useful info about anything...
Class and Code is always the same values, and the mssage name is always NULL.
I don't get what this is for :-/
#include <exec/types.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/notify.h>
#include <stdio.h>
#include <stdarg.h>
#include <proto/exec.h>
#include <proto/dos.h>
struct NotifyRequest * set_notify ( char * fname , struct MsgPort * port )
{
struct NotifyRequest * nr ;
#if 1
if ( nr = AllocVec ( sizeof ( struct NotifyRequest ), MEMF_CLEAR ) )
{
nr -> nr_Name = fname ;
nr -> nr_Flags = NRF_SEND_MESSAGE | NRF_WAIT_REPLY ;
nr -> nr_stuff . nr_Msg . nr_Port = port ;
}
#else
nr = AllocSysObjectTags ( DOS_NOTIFYREQUEST ,
ADO_NotifyName , fname ,
ADO_NotifyMethod , NRF_SEND_MESSAGE ,
ADO_NotifyPort , port ,
// ADO_NotifyWaitReply, TRUE,
TAG_END ) ;
#endif
return nr ;
}
int main ( int argc , char ** args )
{
ULONG exitsig = SIGBREAKF_CTRL_E ;
ULONG signals , sigmask = exitsig ;
int rv = RETURN_OK ;
struct NotifyRequest * nr = NULL ;
struct MsgPort * port ;
struct NotifyMessage * msg ;
if ( argc < 2 )
{
printf ( "Give a arrrrg... :-/" );
return RETURN_FAIL ;
}
port = ( struct MsgPort *) AllocSysObjectTags ( ASOT_PORT , TAG_END );
if (! port ) return RETURN_FAIL ;
if ( nr = set_notify ( args [ 1 ] , port ) )
{
signals = ( 1L << port -> mp_SigBit );
sigmask |= signals ;
}
printf ( "-Wait messages-\n" );
StartNotify ( nr );
if( rv == RETURN_OK )
{
ULONG sigset ;
char * c ;
for(;;)
{
sigset = Wait ( sigmask );
if ( msg = ( struct NotifyMessage *) GetMsg ( port ))
{
printf ( "message recived %x, %x\n" , msg -> nm_Class , msg -> nm_Code );
if ( msg -> nm_ExecMessage . mn_Node . ln_Name ) printf ( "%s\n" , msg -> nm_ExecMessage . mn_Node . ln_Name );
printf ( "nm_DoNotTouch %08x\n" , msg -> nm_DoNotTouch );
printf ( "nm_DoNotTouch2 %08x\n" , msg -> nm_DoNotTouch2 );
c = ( char *) msg -> nm_DoNotTouch2 ;
printf ( "%c,%c\n" ,* c ,*( c + 1 ),*( c + 2 ));
printf ( "nr_DosPrivate %08x\n" , msg -> nm_NReq -> nr_DosPrivate );
printf ( "nr_MsgCount %d\n" , msg -> nm_NReq -> nr_MsgCount );
ReplyMsg ( ( struct Message *) msg );
}
if ( sigset & exitsig ) break;
}
}
printf ( "-Close-\n" );
if ( nr )
{
EndNotify ( nr );
if ( port ) FreeSysObject ( ASOT_PORT , ( APTR ) port );
port = NULL ;
}
return rv ;
}
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/17 10:45
#9
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@LiveForIt
Why do you insist on using message notification type when hook notification type gives more information?
Quote:
struct NotifyHookMsg { int32 nhm_Size; /* Size of data structure */ int32 nhm_Action; /* What happened (see below) */ STRPTR nhm_Name; /* The name of the object */ };Also if you want consistent behavior between filesystems it's recommended to use ADO_DOSMethodOnly that I mentioned before.
Re: File notify question.
Posted on:
2014/2/17 11:04
#10
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@salass00 It was the first thing I tried. Because it did not provide information about sub directory’s. Signaling and Messaging work on subdirectories. Also I don't know what I'm doing wrong whit AllocSysObjectTags,because its only works when setting up the struct Notify manually.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/17 12:59
#11
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@salass00
Some thing is not right whit AllocSysObjectsTags().
nr = AllocSysObjectTags ( DOS_NOTIFYREQUEST ,
ADO_NotifyName , fname ,
ADO_NotifyMethod , NRF_CALL_HOOK ,
ADO_DOSMethodOnly , TRUE ,
ADO_NotifyHook , hook ,
TAG_END ) ;
printf ( "Name: %s\n" , nr -> nr_Name );
printf ( "Flag: %d\n" , nr -> nr_Flags );
printf ( "HOOK: %08X\n" , nr -> nr_stuff . nr_CallHook . nr_Hook );
result: Name: (null)
Flag: 0
HOOK: 5DDCEAA4
if ( nr = AllocVec ( sizeof ( struct NotifyRequest ), MEMF_CLEAR ) )
{
nr -> nr_Name = fname ;
nr -> nr_Flags = NRF_CALL_HOOK ;
nr -> nr_stuff . nr_CallHook . nr_Hook = hook ;
}
printf ( "Name: %s\n" , nr -> nr_Name );
printf ( "Flag: %d\n" , nr -> nr_Flags );
printf ( "HOOK: %08X\n" , nr -> nr_stuff . nr_CallHook . nr_Hook );
result: Name: ram:
Flag: 32
HOOK: 5C673CD4
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/17 13:07
#12
Just popping in
Joined: 2007/5/15 13:42Last Login
: 2023/3/8 14:54
From Austria
Group:
Registered Users
@LiveForIt
Quote:
Some thing is not right whit AllocSysObjectsTags(). Yeah, you are using the wrong function. AllocDosObjectTags() is what you're looking for.
(edit: changed AllocDosObject() to AllocDosObjectTags()
Re: File notify question.
Posted on:
2014/2/17 13:37
#13
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@Gazelle Thanks that worked.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2014/2/17 17:00
#14
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 11/18 16:17
From Finland
Group:
Registered Users
@LiveForIt
For the future in case you didn't already know
:
AllocSysObjectTags()/FreeSysObject() is for ASOT_#? objects
AllocDosObjectTags()/FreeDosObject() is for DOS_#? objects
Re: File notify question.
Posted on:
2014/2/17 17:22
#15
Home away from home
Joined: 2006/11/20 16:26Last Login
: Today 16:51
From Norway
Group:
Registered Users
@salass00 OK thanks, but this API has clearly some limitations. Anyway, two things Notification API, needs to support: * Rename: (Do it the correct way, not say the file is deleted when they are not deleted.) * Support for Sub directory’s.
(NutsAboutAmiga) Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Re: File notify question.
Posted on:
2019/6/18 2:48
#16
Just popping in
Joined: 2015/9/29 0:42Last Login
: 2/25 18:04
From Bettendorf, IA, USA
Group:
Registered Users
@salass00 I needed to update my notification module to handle multiple files being watched. So it requires the hook mode since can't have over 15 signals. I have it all working, but one thing I don't like that needs to be updated: notifyMultiHookFunc(struct Hook *hook,APTR resv UNUSED,struct NotifyHookMsg *msg) msg->nhm_Name only gives me the FilePart of the path I originally specified. Seems like no big deal, but what if I have multiple files of the same name but from different drawers being watched? I need to know specifically which one it is. I need the entire path that I specified to watch. nhm_Path could be added for entire path. But for now, what do I do?
Workbench Explorer - A better way to browse drawers
Re: File notify question.
Posted on:
2019/6/18 9:38
#17
Home away from home
Joined: 2006/12/4 23:15Last Login
: 10/14 16:04
Group:
Registered Users
@mritter0 Use a separate hook for each notification you setup. The hooks will call the same function but you can use the hook data to provide that function with the extra data you need.
Re: File notify question.
Posted on:
2019/6/18 21:17
#18
Just popping in
Joined: 2015/9/29 0:42Last Login
: 2/25 18:04
From Bettendorf, IA, USA
Group:
Registered Users
@broadblues Thanks for the idea. That is what I did. Hopefully the full path will be added so I can use 1 global hook instead of multiple hooks.
Re: File notify question.
Posted on:
2019/6/18 21:29
#19
Home away from home
Joined: 2006/12/4 23:15Last Login
: 10/14 16:04
Group:
Registered Users
@mritter0 Since you need to set the hook for each directory / file monitored seprate hooks is the correct way to go, to avoid race type conditions on more complex hook data. But there is also the "DOSFileDirNotify.resource" which since version 53.81 can setup a global hook to monitor all notification activity. I use this for my activityMonitor application which before that needed to set 1000s of notifications up. See SDK:Include/include_h/resources/filedirnotify.h
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)