Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Finish NSFileHandle's stubbed methods#2477

Merged
DHowett-MSFT merged 2 commits into
microsoft:developfrom
DHowett-MSFT:201704-nsfilehandle
Apr 11, 2017
Merged

Finish NSFileHandle's stubbed methods#2477
DHowett-MSFT merged 2 commits into
microsoft:developfrom
DHowett-MSFT:201704-nsfilehandle

Conversation

@DHowett-MSFT

Copy link
Copy Markdown

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];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

TakeOwnership LIIIIIIVESSSSSSSSS

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😱

- (instancetype)_initWithFileAtPath:(NSString*)file openType:(_NSFileOpenMode)type {
if (file == nil) {
[self release];
return nil;

Copy link
Copy Markdown
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.

O_RDWR | _O_CREAT | O_APPEND | _O_BINARY,
_SH_DENYNO,
_S_IREAD | _S_IWRITE);
default:

Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread Frameworks/Foundation/NSFileHandle.mm Outdated
NSString* const NSFileHandleNotificationDataItem = @"NSFileHandleNotificationDataItem";
NSString* const NSFileHandleOperationException = @"NSFileHandleOperationException";
NSString* const NSFileHandleNotificationMonitorModes = @"NSFileHandleNotificationMonitorModes";
NSString* const NSFileHandleConnectionAcceptedNotification = @"NSFileHandleConnectionAccepted";

Copy link
Copy Markdown
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?


/**
@Status Stub
@Notes

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 :(


/**
@Status Stub
@Notes

Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete NSFileHandle stubs

5 participants