Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
54 user(s) are online (39 user(s) are browsing Forums)

Members: 0
Guests: 54

more...
Support us!
Recent OS4 Files
OS4Depot.net





File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
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.
   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@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.
   Report Go to top

Re: File notify question.
Just can't stay away
Joined:
2008/1/6 17:56
From Pennsylvania, USA
Posts: 1325
@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

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@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.
   Report Go to top

Re: File notify question.
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1112
@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

   Report Go to top

Re: File notify question.
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1690
@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).

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@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.
   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
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 *fnamestruct 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
    
nrAllocSysObjectTagsDOS_NOTIFYREQUEST
            
ADO_NotifyNamefname,
            
ADO_NotifyMethodNRF_SEND_MESSAGE,
            
ADO_NotifyPortport,
//            ADO_NotifyWaitReply, TRUE,
            
TAG_END ) ;
#endif
    
return nr;
}

int mainint argc char **args)
{
    
ULONG exitsig SIGBREAKF_CTRL_E;
    
ULONG signalssigmask 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 *) AllocSysObjectTagsASOT_PORTTAG_END );
    if (!
port)     return RETURN_FAIL;

    if (
nrset_notifyargs[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, %xn"msg -> nm_Classmsg -> nm_Code );

                if (
msg -> nm_ExecMessage.mn_Node.ln_Nameprintf("%sn",msg -> nm_ExecMessage.mn_Node.ln_Name);

                    
printf("nm_DoNotTouch %08xn"msg -> nm_DoNotTouch);
                    
printf("nm_DoNotTouch2 %08xn"msg -> nm_DoNotTouch2);  
                
                
= (char *) msg -> nm_DoNotTouch2;
                
printf("%c,%cn",*c,*(c+1),*(c+2));

                    
printf("nr_DosPrivate %08xn"msg -> nm_NReq -> nr_DosPrivate);
                    
printf("nr_MsgCount %dn"msg -> nm_NReq -> nr_MsgCount);  

                
ReplyMsg( (struct Message *) msg);
            }

            if (
sigset exitsig ) break;
        }    
    }
    
    
printf("-Close-n");

    if (
nr)
    {
            
EndNotify(nr);

        if (
portFreeSysObjectASOT_PORT, (APTRport );
        
port NULL;
    }

    return 
rv;
}

_________________
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
   Report Go to top

Re: File notify question.
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1690
@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.

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@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.
   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@salass00

Some thing is not right whit AllocSysObjectsTags().

nrAllocSysObjectTagsDOS_NOTIFYREQUEST
            
ADO_NotifyNamefname,
            
ADO_NotifyMethodNRF_CALL_HOOK,
            
ADO_DOSMethodOnlyTRUE,
            
ADO_NotifyHookhook,
            
TAG_END ) ;

    
printf("Name: %sn"nr->nr_Name);
    
printf("Flag: %dn",nr->nr_Flags);
    
printf("HOOK: %08Xn"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: %sn"nr->nr_Name);
    
printf("Flag: %dn",nr->nr_Flags);
    
printf("HOOK: %08Xn"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.
   Report Go to top

Re: File notify question.
Just popping in
Joined:
2007/5/15 12:42
From Austria
Posts: 104
@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()

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@Gazelle

Thanks that worked.

_________________
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
   Report Go to top

Re: File notify question.
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1690
@LiveForIt

For the future in case you didn't already know :

AllocSysObjectTags()/FreeSysObject() is for ASOT_#? objects

AllocDosObjectTags()/FreeDosObject() is for DOS_#? objects

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/11/20 16:26
From Norway
Posts: 2740
@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.
   Report Go to top

Re: File notify question.
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 215
@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
   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/12/4 23:15
Posts: 2145
@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.

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: File notify question.
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 215
@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.

   Report Go to top

Re: File notify question.
Home away from home
Joined:
2006/12/4 23:15
Posts: 2145
@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

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project