Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
95 user(s) are online (43 user(s) are browsing Forums)

Members: 0
Guests: 95

more...

Headlines

 
  Register To Post  

File notify question.
Home away from home
Home away from home


See User information
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.
Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.
Go to top
Re: File notify question.
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.
Go to top
Re: File notify question.
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: File notify question.
Just can't stay away
Just can't stay away


See User information
@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).

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.
Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
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, %x\n"msg -> nm_Classmsg -> nm_Code );

                if (
msg -> nm_ExecMessage.mn_Node.ln_Nameprintf("%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);  
                
                
= (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 (
portFreeSysObjectASOT_PORT, (APTRport );
        
port NULL;
    }

    return 
rv;
}

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: File notify question.
Just can't stay away
Just can't stay away


See User information
@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.

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.
Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@salass00

Some thing is not right whit AllocSysObjectsTags().

nrAllocSysObjectTagsDOS_NOTIFYREQUEST
            
ADO_NotifyNamefname,
            
ADO_NotifyMethodNRF_CALL_HOOK,
            
ADO_DOSMethodOnlyTRUE,
            
ADO_NotifyHookhook,
            
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.
Go to top
Re: File notify question.
Just popping in
Just popping in


See User information
@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()

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@Gazelle

Thanks that worked.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: File notify question.
Just can't stay away
Just can't stay away


See User information
@LiveForIt

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

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

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

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.
Go to top
Re: File notify question.
Just popping in
Just popping in


See User information
@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
Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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.

Go to top
Re: File notify question.
Just popping in
Just popping in


See User information
@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.

Go to top
Re: File notify question.
Home away from home
Home away from home


See User information
@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

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project