Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish NSFileHandle's stubbed methods #2477

Merged
merged 2 commits into from
Apr 11, 2017

Conversation

DHowett-MSFT
Copy link

This commit marks roughly half of NSFileHandle's APIs NotInPlan.
WinSock deals in opaque handles which cannot be used with
open/close/seek/tell/read/write, so most of NSFileHandle's APIs cannot
be supported with the POSIX File Descriptor interface.

The background APIs are better suited to use with a socket than with a
file, so until somebody asks for socket support, we will mark them
unplanned.

File handles cannot be coded except through IPC coders, but WinObjC does
not have any IPC coders.

Fixes #2367.

This commit marks roughly half of NSFileHandle's APIs NotInPlan.
WinSock deals in opaque handles which cannot be used with
open/close/seek/tell/read/write, so most of NSFileHandle's APIs cannot
be supported with the POSIX File Descriptor interface.

The background APIs are better suited to use with a socket than with a
file, so until somebody asks for socket support, we will mark them
unplanned.

File handles cannot be coded except through IPC coders, but WinObjC does
not have any IPC coders.

Fixes microsoft#2367.
}

/**
@Status Interoperable
*/
+ (NSFileHandle*)fileHandleWithNullDevice {
return [[_NSFileHandleNullDevice new] autorelease];
static StrongId<NSFileHandle> nullDeviceHandle{ woc::TakeOwnership, [_NSFileHandleNullDevice new] };
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TakeOwnership LIIIIIIVESSSSSSSSS

@Status Caveat
@Notes NSFileHandle only supports file URLs.
*/
+ (instancetype)fileHandleForReadingFromURL:(NSURL*)url error:(NSError* _Nullable*)error {
return [NSFileHandle _fileHandleForURl:url error:error openType:_NSFileOpenModeRead];
return [NSFileHandle _fileHandleForURL:url error:error openType:_NSFileOpenModeRead];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱

if (file == nil) {
[self release];
return nil;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: empty space after curly brace.

_SH_DENYNO,
_S_IREAD | _S_IWRITE);
default:
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is internal, should we fail if we get an invalid type?

- (void)waitForDataInBackgroundAndNotifyForModes:(NSArray*)modes STUB_METHOD;
@property (readonly) int fileDescriptor;
@property (readonly, copy) NSData* availableData;
@property (readonly) unsigned long long offsetInFile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super duper ultra nit: no implied int

@@ -28,6 +28,10 @@
NSString* const NSFileHandleNotificationDataItem = @"NSFileHandleNotificationDataItem";
NSString* const NSFileHandleOperationException = @"NSFileHandleOperationException";
NSString* const NSFileHandleNotificationMonitorModes = @"NSFileHandleNotificationMonitorModes";
NSString* const NSFileHandleConnectionAcceptedNotification = @"NSFileHandleConnectionAccepted";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to "fix" these strings if they are not the right values already?

@@ -175,37 +121,103 @@ + (instancetype)fileHandleForUpdatingAtPath:(NSString*)file {
}

/**
@Status Stub
@Notes
@Status Caveat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header file must be updated too, to remove the STUB_* macros (and add NOTINPLAN_* macros where applicable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header was updated 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh I can't see things today, my bad :(

@@ -175,37 +121,103 @@ + (instancetype)fileHandleForUpdatingAtPath:(NSString*)file {
}

/**
@Status Stub
@Notes
@Status Caveat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh I can't see things today, my bad :(

@DHowett-MSFT DHowett-MSFT merged commit 4c0ff52 into microsoft:develop Apr 11, 2017
@DHowett-MSFT DHowett-MSFT deleted the 201704-nsfilehandle branch April 13, 2017 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complete NSFileHandle stubs
5 participants