summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/ofilenotify.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/ofilenotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/ofilenotify.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/ofilenotify.cpp
index b576c4f..2a9bb8c 100644
--- a/libopie2/opiecore/ofilenotify.cpp
+++ b/libopie2/opiecore/ofilenotify.cpp
@@ -204,96 +204,98 @@ bool OFileNotification::hasChanged()
qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno );
qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime );
qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime );
qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime );
if ( !c && (_type & Create) &&
(long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 &&
(long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0)
{
qDebug( "OFileNotification::hasChanged(): file has been created" );
c = true;
}
if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0)
{
qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" );
c = true;
}
if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime )
{
qDebug( "OFileNotification::hasChanged(): atime changed" );
c = true;
}
if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime )
{
qDebug( "OFileNotification::hasChanged(): mtime changed" );
c = true;
}
if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime )
{
qDebug( "OFileNotification::hasChanged(): ctime changed" );
c = true;
}
return c;
}
void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type )
{
OFileNotification* ofn = new OFileNotification();
ofn->_signal.connect( receiver, member );
ofn->start( path, true, type );
}
void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data )
{
+ Q_UNUSED( sig )
+ Q_UNUSED( data )
qWarning( "OFileNotification::__signalHandler(): reached." );
int fd = si->si_fd;
OFileNotification* fn = notification_list[fd];
if ( fn )
{
// check if it really was the file (dnotify triggers on directory granularity, not file granularity)
if ( !fn->activate() )
{
qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." );
if ( !(fn->type() & Multi ) )
{
int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() );
if ( result == -1 )
{
qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) );
}
}
return;
}
#if 1
if ( !(fn->type() & Multi) )
{
qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd );
notification_list.remove( fd );
if ( notification_list.isEmpty() )
{
OFileNotification::unregisterSignalHandler();
}
}
#endif
}
else
{
qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" );
}
}
bool OFileNotification::registerSignalHandler()
{
struct sigaction act;
act.sa_sigaction = OFileNotification::__signalHandler;
::sigemptyset( &act.sa_mask );
act.sa_flags = SA_SIGINFO;
if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 )
{
qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) );
return false;