kazu-yamamoto / simple-sendfile

Cross platform library for the sendfile system call
BSD 3-Clause "New" or "Revised" License
15 stars 11 forks source link

allow using ByteString instead of FilePath #20

Closed hasufell closed 8 years ago

hasufell commented 8 years ago

String is a dangerous type when dealing with low-level functions like the ones from the unix file package. It's debatable whether it's a good idea at all to represent paths by Strings, since they depend on semi-random encoding, which can lead to subtle bugs.

Since packages like unix already provide safe ByteString variants like System.Posix.Files.ByteString it would make sense that a low-level library like simple-sendfile also allows to deal with filepaths as ByteStrings.

kazu-yamamoto commented 8 years ago

Again, I have no objections to add a new APIs. But I am not motivated because WAI, the biggest client of this package, uses FilePath to support all platforms. I would rather interested in AFPP. So, please do it by yourself and give me a pull request.

hasufell commented 8 years ago

The problem is that I don't know how you want to structure such an API. I tried to do that for the hinotify package but the FilePath type was so deep in the data structures that it was very hard to make an Internal module that provides the base for both APIs. The easiest way is to start with copy-paste and then do the changes, same for #19

kazu-yamamoto commented 8 years ago

I agree that copy-paste is reasonable at the beginning. :-)