Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
* release/1.1.2: (21 commits)
  Bumb version to 1.1.2.
  Fix lastEvent not getting set.
  compatibility shim, runtime checking example, file-level events ---------------------------------------------------------------
  validate project settings, update to xcode 3.2
  Fixed "missing base SDK".
  Fixed a bug in the CDEventsCallback(...) code which could cause the excludedURLs to be disregarded.
  Changed the lastEvent property of the CDEvents class to readonly in public and readwrite in private.
  Fixed a bug in the test app which could cause an exception to be raised.
  Fixed a lot of small formatting and cross reference errors in the API doc.
  Fixed a dup symbols bug properly, thanks to Kirk Kerekes.
  Defined MACOSX_DEPLOYMENT_TARGET to 10.5.
  Added some Xcode 4 stuff to the git ignore file.
  Revert "Changed two "const <type> <name>" constants to macros (they caused duplicate symbol linking errors when the header was included more than once for the same product)."
  Fixed small markdown error.
  Added still maintained image.
  Changed two "const <type> <name>" constants to macros (they caused duplicate symbol linking errors when the header was included more than once for the same product).
  Changed test application to use full CDEvents init method.
  Fixed missing __weak code mark in the delegate property declaration.
  Changed the compiler to LLVM 1.5.
  Marked CDEventsDelegate pointer as a weak pointer (for GC).
  ...

Conflicts:
	CDEvents.xcodeproj/project.pbxproj
  • Loading branch information
rastersize committed Oct 24, 2011
2 parents c728faf + 3987ddc commit d560344
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 149 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.svn

*.swp
*.o
*.lo
.libs
*.la

.DS_Store

build

*.perspectivev3
Expand All @@ -6,6 +16,8 @@ build
*.mode1v3
*.mode2v3
*.tm_build_errors
*.xcodeproj/xcuserdata
*.xcodeproj/project.xcworkspace
!default.pbxuser
!default.perspectivev3
!default.mode1v3
Expand All @@ -14,6 +26,4 @@ build
*~.nib
*~.xib

.DS_Store

api
70 changes: 49 additions & 21 deletions CDEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#import <Foundation/Foundation.h>
#import <CoreServices/CoreServices.h>


#pragma mark -
#pragma mark CDEvent types
/**
Expand Down Expand Up @@ -77,6 +76,7 @@ typedef FSEventStreamEventFlags CDEventFlags;
}

#pragma mark Properties
/** @name Getting Event Properties */
/**
* The event identifier.
*
Expand Down Expand Up @@ -106,6 +106,8 @@ typedef FSEventStreamEventFlags CDEventFlags;
*/
@property (readonly) NSURL *URL;


/** @name Getting Event Flags */
/**
* The flags of the event.
*
Expand All @@ -119,18 +121,26 @@ typedef FSEventStreamEventFlags CDEventFlags;
*/
@property (readonly) CDEventFlags flags;

#pragma mark flag macros

#define FLAG_CHECK(flags, flag) ((flags) & (flag))

#define FLAG_PROPERTY(name, flag) \
- (BOOL)name \
{ return (FLAG_CHECK(_flags, flag) ? YES : NO); }

#pragma mark Specific flag properties
/**
* Wheter there was some change in the directory at the specific path supplied in this event.
*
* @return <code>YES</code> if there was some change in the directory, otherwise <code>NO</code>
* @return <code>YES</code> if there was some change in the directory, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagNone
* @see flags
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeMount
Expand All @@ -148,19 +158,19 @@ typedef FSEventStreamEventFlags CDEventFlags;
* events were coalesced hierarchically. For example, an event in
* <code>/Users/jsmith/Music</code> and an event in
* <code>/Users/jsmith/Pictures</code> might be coalesced into an event with
* this flag set and <i>URL</i><code>=/Users/jsmith</code>. If this flag is set
* this flag set and URL <code>= /Users/jsmith</code>. If this flag is set
* you may be able to get an idea of whether the bottleneck happened in the
* kernel (less likely) or in your client (more likely) by checking if
* flagUserDropped or flagKernelDropped returns <code>YES</code>.
* isUserDropped or isKernelDropped returns <code>YES</code>.
*
* @return <code>YES</code> if you must rescan the whole directory including its children, otherwise <code>NO</code>
* @return <code>YES</code> if you must rescan the whole directory including its children, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagMustScanSubDirs
* @see flags
* @see isGenericChange
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeMount
Expand All @@ -173,14 +183,14 @@ typedef FSEventStreamEventFlags CDEventFlags;
/**
* Provides some information as to what might have caused the need to rescan the URL including its children.
*
* @return <code>YES</code> if mustRescanSubDirectories returns <code>YES</code> and the cause were in userland, otherwise <code>NO</code>
* @return <code>YES</code> if mustRescanSubDirectories returns <code>YES</code> and the cause were in userland, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagUserDropped
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeMount
Expand All @@ -193,14 +203,14 @@ typedef FSEventStreamEventFlags CDEventFlags;
/**
* Provides some information as to what might have caused the need to rescan the URL including its children.
*
* @return <code>YES</code> if mustRescanSubDirectories returns <code>YES</code> and the cause were in kernelspace, otherwise <code>NO</code>
* @return <code>YES</code> if mustRescanSubDirectories returns <code>YES</code> and the cause were in kernelspace, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagKernelDropped
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeMount
Expand All @@ -217,7 +227,7 @@ typedef FSEventStreamEventFlags CDEventFlags;
* previously-issued event identifiers are no longer valid arguments for the
* sinceEventIdentifier parameter of the CDEvents init methods.
*
* @return <code>YES</code> if the 64-bit event identifier counter has wrapped around, otherwise <code>NO</code>
* @return <code>YES</code> if the 64-bit event identifier counter has wrapped around, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagEventIdsWrapped
* @see flags
Expand All @@ -241,15 +251,15 @@ typedef FSEventStreamEventFlags CDEventFlags;
* as a result of specifying a <i>sinceEventIdentifier</i> argument other than
* kCDEventsSinceEventNow with the CDEvents init methods.
*
* @return <code>YES</code> if if the event is sent to mark the end of the "historical" events sent, otherwise <code>NO</code>
* @return <code>YES</code> if if the event is sent to mark the end of the "historical" events sent, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagHistoryDone
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isRootChanged
* @see didVolumeMount
* @see didVolumeUnmount
Expand All @@ -271,15 +281,15 @@ typedef FSEventStreamEventFlags CDEventFlags;
* with this flag set will only be sent if you passed the flag
* <code>kFSEventStreamCreateFlagWatchRoot</code> to the CDEvents.
*
* @return <code>YES</code> if there is a change to one of the URLs you asked to watch, otherwise <code>NO</code>
* @return <code>YES</code> if there is a change to one of the URLs you asked to watch, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagRootChanged
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see didVolumeMount
* @see didVolumeUnmount
Expand All @@ -304,15 +314,15 @@ typedef FSEventStreamEventFlags CDEventFlags;
* Also be aware of the <code>MNT_DONTBROWSE</code> flag that is set for volumes
* which should not be displayed by user interface elements.
*
* @return <code>YES</code> if a volumen is mounted underneath one of the URLs being watched, otherwise <code>NO</code>
* @return <code>YES</code> if a volumen is mounted underneath one of the URLs being watched, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagMount
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeUnmount
Expand All @@ -333,15 +343,15 @@ typedef FSEventStreamEventFlags CDEventFlags;
* could uncover an arbitrarily large directory hierarchy, although Mac OS X
* never does that.
*
* @return <code>YES</code> if a volume is unmounted underneath one of the URLs being watched, otherwise <code>NO</code>
* @return <code>YES</code> if a volume is unmounted underneath one of the URLs being watched, otherwise <code>NO</code>.
*
* @see kFSEventStreamEventFlagUnmount
* @see flags
* @see isGenericChange
* @see mustRescanSubDirectories
* @see isUserDropped
* @see isKernelDropped
* @see isEventIdsWrapped
* @see isEventIdentifiersWrapped
* @see isHistoryDone
* @see isRootChanged
* @see didVolumeMount
Expand All @@ -351,8 +361,26 @@ typedef FSEventStreamEventFlags CDEventFlags;
@property (readonly) BOOL didVolumeUnmount;


#pragma mark Class object creators
/**
* The entirety of the documentation on file level events in lion is 3 sentences
* long. Rename behavior is odd, making the combination of events and flags
* somewhat confusing for atomic writes. It also appears possible to get a
* singular event where a file has been created, modified, and removed.
*/
@property (readonly) BOOL isCreated;
@property (readonly) BOOL isRemoved;
@property (readonly) BOOL isInodeMetadataModified;
@property (readonly) BOOL isRenamed;
@property (readonly) BOOL isModified;
@property (readonly) BOOL isFinderInfoModified;
@property (readonly) BOOL didChangeOwner;
@property (readonly) BOOL isXattrModified;
@property (readonly) BOOL isFile;
@property (readonly) BOOL isDir;
@property (readonly) BOOL isSymlink;

#pragma mark Class object creators
/** @name Creating CDEvent Objects */
/**
* Returns an <code>CDEvent</code> created with the given identifier, date, URL and flags.
*
Expand Down
63 changes: 22 additions & 41 deletions CDEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/

#import "CDEvent.h"

#import "compat.h"

@implementation CDEvent

Expand Down Expand Up @@ -104,52 +104,33 @@ - (id)copyWithZone:(NSZone *)zone
return [self retain];
}


#pragma mark Specific flag properties
- (BOOL)isGenericChange
{
return (kFSEventStreamEventFlagNone == _flags);
}

- (BOOL)mustRescanSubDirectories
{
return (_flags & kFSEventStreamEventFlagMustScanSubDirs);
}

- (BOOL)isUserDropped
{
return (_flags & kFSEventStreamEventFlagUserDropped);
}

- (BOOL)isKernelDropped
{
return (_flags & kFSEventStreamEventFlagKernelDropped);
}

- (BOOL)isEventIdentifiersWrapped
{
return (_flags & kFSEventStreamEventFlagEventIdsWrapped);
}

- (BOOL)isHistoryDone
{
return (_flags & kFSEventStreamEventFlagHistoryDone);
}

- (BOOL)isRootChanged
{
return (_flags & kFSEventStreamEventFlagRootChanged);
}

- (BOOL)didVolumeMount
{
return (_flags & kFSEventStreamEventFlagMount);
}

- (BOOL)didVolumeUnmount
{
return (_flags & kFSEventStreamEventFlagUnmount);
}
FLAG_PROPERTY(mustRescanSubDirectories, kFSEventStreamEventFlagMustScanSubDirs)
FLAG_PROPERTY(isUserDropped, kFSEventStreamEventFlagUserDropped)
FLAG_PROPERTY(isKernelDropped, kFSEventStreamEventFlagKernelDropped)
FLAG_PROPERTY(isEventIdentifiersWrapped, kFSEventStreamEventFlagEventIdsWrapped)
FLAG_PROPERTY(isHistoryDone, kFSEventStreamEventFlagHistoryDone)
FLAG_PROPERTY(isRootChanged, kFSEventStreamEventFlagRootChanged)
FLAG_PROPERTY(didVolumeMount, kFSEventStreamEventFlagMount)
FLAG_PROPERTY(didVolumeUnmount, kFSEventStreamEventFlagUnmount)

// file-level events introduced in 10.7
FLAG_PROPERTY(isCreated, kFSEventStreamEventFlagItemCreated)
FLAG_PROPERTY(isRemoved, kFSEventStreamEventFlagItemRemoved)
FLAG_PROPERTY(isInodeMetadataModified, kFSEventStreamEventFlagItemInodeMetaMod)
FLAG_PROPERTY(isRenamed, kFSEventStreamEventFlagItemRenamed)
FLAG_PROPERTY(isModified, kFSEventStreamEventFlagItemModified)
FLAG_PROPERTY(isFinderInfoModified, kFSEventStreamEventFlagItemFinderInfoMod)
FLAG_PROPERTY(didChangeOwner, kFSEventStreamEventFlagItemChangeOwner)
FLAG_PROPERTY(isXattrModified, kFSEventStreamEventFlagItemXattrMod)
FLAG_PROPERTY(isFile, kFSEventStreamEventFlagItemIsFile)
FLAG_PROPERTY(isDir, kFSEventStreamEventFlagItemIsDir)
FLAG_PROPERTY(isSymlink, kFSEventStreamEventFlagItemIsSymlink)

#pragma mark Misc
- (NSString *)description
Expand Down
Loading

0 comments on commit d560344

Please sign in to comment.