<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac / iPhone App Development &#187; file monitor</title>
	<atom:link href="http://benreeves.co.uk/tag/file-monitor/feed/" rel="self" type="application/rss+xml" />
	<link>http://benreeves.co.uk</link>
	<description>Home of a Small Time Developer</description>
	<lastBuildDate>Wed, 26 May 2010 14:24:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone File System Monitor</title>
		<link>http://benreeves.co.uk/iphone-file-system-monitor/</link>
		<comments>http://benreeves.co.uk/iphone-file-system-monitor/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 19:04:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[file monitor]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.benreeves.co.uk/?p=111</guid>
		<description><![CDATA[I require simple for system monitoring for a new (undisclosed) iphone project. It doesn&#8217;t appear that there is any equivilant to ionotify for the iphone, so I whipped up this polling file system monitor which meets my basic requirements. If you find this code useful feel free to use / distribute etc.

#include &#34;FileSystemMonitor.h&#34;
&#160;
//Setup the monitor
FileSystemMonitor [...]]]></description>
			<content:encoded><![CDATA[<p>I require simple for system monitoring for a new (undisclosed) iphone project. It doesn&#8217;t appear that there is any equivilant to ionotify for the iphone, so I whipped up this polling file system monitor which meets my basic requirements. If you find this code useful feel free to use / distribute etc.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#include &quot;FileSystemMonitor.h&quot;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">//Setup the monitor</span>
FileSystemMonitor <span style="color: #002200;">*</span> monitor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>FileSystemMonitor alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
monitor.delegate <span style="color: #002200;">=</span> self;
<span style="color: #002200;">&#91;</span>monitor monitorPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">//...In your delegate class</span>
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>nodeWasCreatedAt<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path
<span style="color: #002200;">&#123;</span>
     <span style="color: #a61390;">printf</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;Created %s<span style="color: #2400d9;">\n</span>&quot;</span>, <span style="color: #002200;">&#91;</span>path UTF8String<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>nodeWasDeletedAt<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">printf</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;Deleted %s<span style="color: #2400d9;">\n</span>&quot;</span>, <span style="color: #002200;">&#91;</span>path UTF8String<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fileSizeDidchange<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path bytes<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">size_t</span><span style="color: #002200;">&#41;</span>difference
<span style="color: #002200;">&#123;</span>
     <span style="color: #a61390;">printf</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;file Added %ul bytes<span style="color: #2400d9;">\n</span>&quot;</span>, difference<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><strong>Notes:</strong></p>
<ul>
<li>Can monitor for Deleted files, Created Files and File Size Changes</li>
<li>On an iPhone 3GS it is able to monitor the entire SVN 1.6 source tree and the iVersion source tree (total 11,050 File/Directories) in an execution time of 12s. Due to the low thread priority and the fact that the majority of execution time is IO it does not cause much/any slow down to the UI. However there is still room for improvement.</li>
</ul>
<p><strong>Download:</strong></p>
<p><strong><a href="http://www.benreeves.co.uk/wp-content/uploads/2010/01/FileSystemMonitor.h">FileSystemMonitor.h</a></strong></p>
<p><strong><a href="http://www.benreeves.co.uk/wp-content/uploads/2010/01/FileSystemMonitor.m">FileSystemMonitor.m</a></strong></p>
<p><strong><a href="http://www.benreeves.co.uk/wp-content/uploads/2010/01/FileMonitorDelegateProtocol.h">FileMonitorDelegateProtocol.h</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://benreeves.co.uk/iphone-file-system-monitor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
