<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -88,4 +88,15 @@
 */
 - (NSString *) filePath;
 
+/*!
+    @method     
+    @abstract   Delete any temp files created through this NSFileHandle category.
+    @discussion
+    This feels slightly hacky, but it gives a simple way to clean up any temporary
+    files created when your application exits.  It doesn't take into account any
+    files you have deleted yourself, but it won't balk at them either.
+*/
++ (void) deleteTemporaryFiles;
+
+
 @end</diff>
      <filename>TempFiles/NSFileHandle+TempFile.h</filename>
    </modified>
    <modified>
      <diff>@@ -40,8 +40,26 @@
 #import &lt;sys/fcntl.h&gt;
 #import &lt;sys/param.h&gt;
 
+static NSMutableSet * __tempFileStore = nil;
+
 @implementation NSFileHandle (AQTempFile)
 
++ (void) initializeTempFileStore
+{
+    if ( __tempFileStore != nil )
+        return;
+    
+    // double-checked locking can bite you. This routine is designed for
+    //  rare use, so it shouldn't be a problem here, but to understand
+    //  why it's often a bad idea, look here:
+    //  http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
+    @synchronized(self)
+    {
+        if ( __tempFileStore == nil )
+            __tempFileStore = [[NSMutableSet alloc] init];
+    }
+}
+
 + (NSFileHandle *) tempFile
 {
     return ( [[[self alloc] initTempFile] autorelease] );
@@ -72,6 +90,13 @@
     if ( fd == -1 )
         return ( nil );
     
+    [[self class] initializeTempFileStore];
+    
+    @synchronized(__tempFileStore)
+    {
+        [__tempFileStore addObject: [NSString stringWithUTF8String: cStr]];
+    }
+    
     return ( [self initWithFileDescriptor: fd] );
 }
 
@@ -99,4 +124,22 @@
     return ( [NSString stringWithUTF8String: buf] );
 }
 
++ (void) deleteTemporaryFiles
+{
+    if ( __tempFileStore == nil )
+        return;
+    
+    @synchronized(__tempFileStore)
+    {
+        NSFileManager * fm = [NSFileManager defaultManager];
+        
+        for ( NSString * path in [__tempFileStore allObjects] )
+        {
+            [fm removeItemAtPath: path error: NULL];
+        }
+        
+        [__tempFileStore removeAllObjects];
+    }
+}
+
 @end</diff>
      <filename>TempFiles/NSFileHandle+TempFile.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b2f31352dc72a6df6637c8680070cdbca6fb6c17</id>
    </parent>
  </parents>
  <author>
    <name>Jim Dovey</name>
    <email>jimdovey@mac.com</email>
  </author>
  <url>http://github.com/AlanQuatermain/aqtoolkit/commit/745cdd4bb92aad7f4a5de7e36176e3f308463645</url>
  <id>745cdd4bb92aad7f4a5de7e36176e3f308463645</id>
  <committed-date>2009-04-11T10:00:53-07:00</committed-date>
  <authored-date>2009-04-11T10:00:53-07:00</authored-date>
  <message>Added storage for temp-file paths, and a class method to remove them all from disk.</message>
  <tree>949e95c91297b94ce2ba077319029e5fb3cdeb42</tree>
  <committer>
    <name>Jim Dovey</name>
    <email>jimdovey@mac.com</email>
  </committer>
</commit>
