Removed unused file watcher

This commit is contained in:
Michael Starke
2018-09-11 15:04:16 +02:00
parent bdd7d22e7c
commit fc5a054fed
3 changed files with 0 additions and 145 deletions

View File

@@ -190,7 +190,6 @@
4C888C9316EB6F5E003D34A1 /* MPToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9216EB6F5E003D34A1 /* MPToolbarItem.m */; };
4C888C9716EB754B003D34A1 /* MPActionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C888C9616EB754B003D34A1 /* MPActionHelper.m */; };
4C88C66918D9F8D600F43852 /* MPTemporaryFileStorageCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C88C66818D9F8D600F43852 /* MPTemporaryFileStorageCenter.m */; };
4C8913661A422C8C0071A4CB /* MPFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8913651A422C8C0071A4CB /* MPFileWatcher.m */; };
4C8990F71EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C8990F51EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m */; };
4C89B71019B4B4A300DC0A6A /* MPTreeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C89B70F19B4B4A300DC0A6A /* MPTreeDelegate.m */; };
4C89F524182FB4740069C73C /* MPAutotypeCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C89F523182FB4740069C73C /* MPAutotypeCommand.m */; };
@@ -671,8 +670,6 @@
4C888C9616EB754B003D34A1 /* MPActionHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPActionHelper.m; sourceTree = "<group>"; };
4C88C66718D9F8D600F43852 /* MPTemporaryFileStorageCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTemporaryFileStorageCenter.h; sourceTree = "<group>"; };
4C88C66818D9F8D600F43852 /* MPTemporaryFileStorageCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTemporaryFileStorageCenter.m; sourceTree = "<group>"; };
4C8913641A422C8C0071A4CB /* MPFileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPFileWatcher.h; sourceTree = "<group>"; };
4C8913651A422C8C0071A4CB /* MPFileWatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPFileWatcher.m; sourceTree = "<group>"; };
4C8990F41EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDuplicateEntryOptionsWindowController.h; sourceTree = "<group>"; };
4C8990F51EE978EB0043B48D /* MPDuplicateEntryOptionsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDuplicateEntryOptionsWindowController.m; sourceTree = "<group>"; };
4C89B70E19B4B4A300DC0A6A /* MPTreeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTreeDelegate.h; sourceTree = "<group>"; };
@@ -1118,8 +1115,6 @@
4C4B728418E4B9B400A1A5D5 /* MPDockTileHelper.m */,
4CB63A6018986530002DEC4C /* MPFlagsHelper.h */,
4C978E0C19AE54AB003067DF /* MPFlagsHelper.m */,
4C8913641A422C8C0071A4CB /* MPFileWatcher.h */,
4C8913651A422C8C0071A4CB /* MPFileWatcher.m */,
);
name = Helper;
sourceTree = "<group>";
@@ -1974,7 +1969,6 @@
4CE5B54B173AFBA700207B39 /* MPDocument.m in Sources */,
4CE082C31F6FCD2A0034FF56 /* MPCollectionView.m in Sources */,
4C4A100F176286FD00BBF2CA /* MPTableView.m in Sources */,
4C8913661A422C8C0071A4CB /* MPFileWatcher.m in Sources */,
4CA334CA18AD60D1008A3322 /* MPWindowAssociationsTableViewDelegate.m in Sources */,
4C01C2421764D8980016D5D0 /* MPContextMenuHelper.m in Sources */,
4CE296191842A166005F01CE /* MPAutotypePaste.m in Sources */,

View File

@@ -1,39 +0,0 @@
//
// MPFileWatcher.h
// MacPass
//
// Created by Michael Starke on 17/12/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import <Foundation/Foundation.h>
@class MPFileWatcher;
typedef void (^MPFileWatcherBlock)(void);
/* TODO: Cocoanetics DTFileMonitor */
@interface MPFileWatcher : NSObject
@property (copy, readonly) NSURL *URL;
+ (instancetype)fileWatcherWithURL:(NSURL *)url changeBlock:(MPFileWatcherBlock)block;
- (instancetype)initWithURL:(NSURL *)url changeBlock:(MPFileWatcherBlock)block;
- (void)startMonitoring;
- (void)stopMonitoring;
@end

View File

@@ -1,100 +0,0 @@
//
// MPFileWatcher.m
// MacPass
//
// Created by Michael Starke on 17/12/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "MPFileWatcher.h"
@interface MPFileWatcher ()
@property (copy) NSURL *URL;
@property (copy) MPFileWatcherBlock block;
@property (assign) int fileDescriptor;
@property (strong) dispatch_queue_t queue;
@property (strong) dispatch_source_t source;
@end
@implementation MPFileWatcher
+ (instancetype)fileWatcherWithURL:(NSURL *)url changeBlock:(MPFileWatcherBlock)block {
return [[MPFileWatcher alloc] initWithURL:url changeBlock:block];
}
- (instancetype)initWithURL:(NSURL *)url changeBlock:(MPFileWatcherBlock)block {
NSAssert([url isFileURL], @"URL needs to be a valid file URL");
self = [super init];
if(self) {
_block = [block copy];
_URL = [url copy];
_queue = dispatch_queue_create("MPFileMonitor Queue", 0);
}
return self;
}
- (void)startMonitoring
{
@synchronized(self) {
if(self.source) {
return;
}
self.fileDescriptor = open([self.URL.path fileSystemRepresentation], O_EVTONLY);
if(!self.fileDescriptor) {
return;
}
// watch the file descriptor for writes
self.source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, self.fileDescriptor, DISPATCH_VNODE_WRITE, self.queue);
// call the passed block if the source is modified
/* dispatch_source_set_event_handler(source, ^{
unsigned long flags = dispatch_source_get_data(source);
if(flags & DISPATCH_VNODE_DELETE) {
dispatch_source_cancel(source);
[blockSelf watchFileAtURL:url];
}
}); */
dispatch_source_set_event_handler(self.source, self.block);
// close the file descriptor when the dispatch source is canceled
dispatch_source_set_cancel_handler(self.source, ^{
close(self.fileDescriptor);
});
// at this point the dispatch source is paused, so start watching
dispatch_resume(self.source);
}
}
- (void)stopMonitoring {
@synchronized(self) {
if(!self.source) {
return;
}
dispatch_source_cancel(self.source);
self.source = nil;
}
}
@end