NSFileVersion additional methods.

This commit is contained in:
Gregory John Casamento 2019-09-23 02:51:41 -04:00
parent 1d04d0c9e9
commit 0644317ab4
4 changed files with 111 additions and 10 deletions

View file

@ -118,11 +118,11 @@ DEFINE_BLOCK_TYPE(GSAccessorHandlerBlock, void, GSBatchAccessorHandler);
error: (NSError **)outError
byAccessor: (GSDualWriteURLCallbackHandler)writer;
- (void)itemAtURL:(NSURL *)oldURL didMoveToURL: (NSURL *)newURL;
- (void)itemAtURL: (NSURL *)oldURL didMoveToURL: (NSURL *)newURL;
- (void)itemAtURL:(NSURL *)oldURL willMoveToURL: (NSURL *)newURL;
- (void)itemAtURL: (NSURL *)oldURL willMoveToURL: (NSURL *)newURL;
- (void)itemAtURL:(NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes;
- (void)itemAtURL: (NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes;
- (void)prepareForReadingItemsAtURLs: (NSArray *)readingURLs
options: (NSFileCoordinatorReadingOptions)readingOptions

View file

@ -37,12 +37,17 @@ enum {
};
typedef NSUInteger NSFileVersionReplacingOptions;
enum {
NSFileVersionAddingByMoving = 1 << 0
};
typedef NSUInteger NSFileVersionAddingOptions;
@interface NSFileVersion : NSObject
{
@private
NSURL *_fileURL;
NSURL *_contentsURL;
id _oersistentIdentifier;
id _persistentIdentifier;
id _nonLocalVersion;
BOOL _isResolved;
BOOL _isDiscardable;
@ -54,6 +59,21 @@ typedef NSUInteger NSFileVersionReplacingOptions;
NSDate *_modificationDate;
}
// Initializers
+ (NSFileVersion *)currentVersionOfItemAtURL: (NSURL *)url;
+ (NSArray *)otherVersionsOfItemAtURL: (NSURL *)url;
+ (NSFileVersion *)versionOfItemAtURL: (NSURL *)url
forPersistentIdentifier: (id)persistentIdentifier;
+ (NSURL *)temporaryDirectoryURLForNewVersionOfItemAtURL: (NSURL *)url;
+ (NSFileVersion *)addVersionOfItemAtURL: (NSURL *)url
withContentsOfURL: (NSURL *)contentsURL
options: (NSFileVersionAddingOptions)options
error: (NSError * _Nullable *)outError;
+ (NSArray *)unresolvedConflictVersionsOfItemAtURL: (NSURL *)url;
+ (BOOL)removeOtherVersionsOfItemAtURL: (NSURL *)url
error: (NSError **)outError;
// instance methods...
- (BOOL) isDiscardable;
- (void) setDiscardable: (BOOL)flag;
- (BOOL) isResolved;

View file

@ -152,7 +152,10 @@ static NSMutableDictionary *__presenterMap = nil;
if(options == 0L)
{
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
[p savePresentedItemChangesWithCompletionHandler:NULL];
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
{
[p savePresentedItemChangesWithCompletionHandler:NULL];
}
}
CALL_BLOCK(reader, url);
}
@ -165,7 +168,10 @@ static NSMutableDictionary *__presenterMap = nil;
if(options == 0L)
{
id<NSFilePresenter> p = [__presenterMap objectForKey: url];
[p savePresentedItemChangesWithCompletionHandler:NULL];
if([p respondsToSelector: @selector(savePresentedItemChangesWithCompletionHandler:)])
{
[p savePresentedItemChangesWithCompletionHandler:NULL];
}
}
CALL_BLOCK(writer, url);
}
@ -179,15 +185,15 @@ static NSMutableDictionary *__presenterMap = nil;
{
}
- (void)itemAtURL:(NSURL *)oldURL didMoveToURL: (NSURL *)newURL
- (void)itemAtURL: (NSURL *)oldURL didMoveToURL: (NSURL *)newURL
{
}
- (void)itemAtURL:(NSURL *)oldURL willMoveToURL: (NSURL *)newURL
- (void)itemAtURL: (NSURL *)oldURL willMoveToURL: (NSURL *)newURL
{
}
- (void)itemAtURL:(NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes
- (void)itemAtURL: (NSURL *)url didChangeUbiquityAttributes: (NSSet *)attributes
{
}

View file

@ -1,7 +1,82 @@
/* Definition of class NSFileVersion
Copyright (C) 2019 Free Software Foundation, Inc.
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
Date: Sep 2019
Original File by: Daniel Ferreira
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
*/
#include <Foundation/NSFileVersion.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSError.h>
#include <Foundation/NSString.h>
#include <Foundation/NSURL.h>
#include <Foundation/NSPersonNameComponents.h>
@implementation NSFileVersion
// Initializers
+ (NSFileVersion *)currentVersionOfItemAtURL: (NSURL *)url
{
return nil;
}
+ (NSArray *)otherVersionsOfItemAtURL: (NSURL *)url
{
return nil;
}
+ (NSFileVersion *)versionOfItemAtURL: (NSURL *)url
forPersistentIdentifier: (id)persistentIdentifier
{
return nil;
}
+ (NSURL *)temporaryDirectoryURLForNewVersionOfItemAtURL: (NSURL *)url
{
return nil;
}
+ (NSFileVersion *)addVersionOfItemAtURL: (NSURL *)url
withContentsOfURL: (NSURL *)contentsURL
options: (NSFileVersionAddingOptions)options
error: (NSError **)outError
{
return nil;
}
+ (NSArray *)unresolvedConflictVersionsOfItemAtURL: (NSURL *)url
{
return nil;
}
+ (BOOL)removeOtherVersionsOfItemAtURL: (NSURL *)url
error: (NSError **)outError
{
return NO;
}
// Instance methods...
- (BOOL) isDiscardable
{
return _isDiscardable;
@ -63,7 +138,7 @@
- (id<NSCoding>) persistentIdentifier
{
return nil;
return _persistentIdentifier;
}
- (BOOL) removeAndReturnError: (NSError **)outError