Skip to content

Conversation

@bsneed
Copy link
Contributor

@bsneed bsneed commented Sep 9, 2021

Reduces file descriptor usage by storing file handle rather than opening a new one with every write.

fileHandle?.seekToEndOfFile()
// prepare for the next entry
if newFile == false {
fileHandle?.write(",".data(using: .utf8)!)
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 absolutely know 100% of the time this explicit will work on all platforms? Makes me uneasy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would it not work on all platforms?? It's almost identical to what it was before and tests are passing hunky dory.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it just being a comma should be okay.

assert(false, "Storage: failed to write event to \(storeFile), error: \(error)")
// write the data
fileHandle?.write(jsonData)
if #available(tvOS 13, *) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be good to add a comment why we are doing this for 13 and above but supporting 11.

@bsneed bsneed merged commit 74839c7 into main Sep 9, 2021
@bsneed bsneed deleted the bsneed/fileio branch September 9, 2021 17:54
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.

3 participants