Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-06-06 Thread Quinn "The Eskimo!" via swift-users
On 5 Jun 2016, at 11:36, Jens Alfke wrote: > It’s almost unique in that regard; in general Cocoa APIs are only supposed to > throw exceptions for programmer errors like assertion failures. Almost unique is right. The only other offender I can think of is Distributed

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-06-05 Thread Brent Royal-Gordon via swift-users
> Looks good, but you'll want some error handling. There's no clean way to > integrate it with Generator because the protocol doesn't allow the > implementation to throw, unfortunately. (I've run into the same problem > building a Generator around a database query.) I think the best solution is

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-06-05 Thread Jens Alfke via swift-users
Looks good, but you'll want some error handling. There's no clean way to integrate it with Generator because the protocol doesn't allow the implementation to throw, unfortunately. (I've run into the same problem building a Generator around a database query.) I think the best solution is to add

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-06-05 Thread Matthias Zenger via swift-users
Quinn, Jens, thanks for pointing me at the NSStream classes. For some reason, I discarded NSStream quickly after seeing the first paragraph of Apple's documentation on output streams

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-06-05 Thread Jens Alfke via swift-users
> On Jun 4, 2016, at 6:25 PM, Matthias Zenger via swift-users > wrote: > > I wanted to use NSFileHandle (for a use case that requires streaming) and > realized that this is an API that cannot really be used in Swift because it's > based on Objective-C exceptions.

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-23 Thread Quinn "The Eskimo!" via swift-users
On 18 May 2016, at 23:02, John Myers via swift-users wrote: > I've been having trouble figuring out how to read and write data to a > textfile, and not finding much out there for Swift on Linux. Sorry about being complicit in the one-shot vs streaming I/O diversion.

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Jens Alfke via swift-users
> On May 20, 2016, at 9:44 AM, Jan Neumüller via swift-users > wrote: > > What advantage? Streaming IO is a pain in the . I never got what people > like at this stuff Well for one, it abstracts away the source of the data. It could be a file, a TCP socket, an HTTP

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-20 Thread Gerard Iglesias via swift-users
Hello Interesting question From my point of view, I want to parse a huge file without loading it in memory... Maybe something worth the reading

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-19 Thread Jens Alfke via swift-users
> On May 19, 2016, at 12:58 AM, Quinn The Eskimo! via swift-users > wrote: > > The reason I ask is that most of the time when I mess around with files I > transfer the entire file to and from memory, which is something that the > Foundation APIs excel at. I believe

Re: [swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-19 Thread Quinn "The Eskimo!" via swift-users
On 18 May 2016, at 23:02, John Myers via swift-users wrote: > I've been having trouble figuring out how to read and write data to a > textfile … Your examples show you transferring the data line-by-line. Is that the end goal? Or just fallout from what you happened

[swift-users] file io in Swift 2.2 for Linux (would like to be pointed in the right direction)

2016-05-18 Thread John Myers via swift-users
I've been having trouble figuring out how to read and write data to a textfile, and not finding much out there for Swift on Linux. I found code for reading data from a file on StackOverflow that works for me, but cludged together my own code for writing to a file. I'm not sure exactly what I'm