Re: [GHC] #7985: Allow openFile on unknown file type

#7985: Allow openFile on unknown file type -------------------------------------+------------------------------------- Reporter: singpolyma | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett):
Just guessing once and for all that files of unknown type are seekable (or not seekable) doesn't seem right.
We ''could'' default to merely claiming a `Stream` as a reasonably safe default. This makes the fewest assumptions about supported operations, and would give back `False` for unknown seekability. This is conservative, but would allow users to at least open and stream content to/from such devices. If users later can point to specific exotic non-posix device types that support seeking then we could toggle on support for them on a case by case basis. This would likely let us simplify the `statGetType` logic a great deal to something like: {{{#!hs statGetType :: Ptr CStat -> IO IODeviceType statGetType p_stat = do c_mode <- st_mode p_stat :: IO CMode case () of _ | s_isdir c_mode -> return Directory | s_isreg c_mode -> return RegularFile | s_isblk c_mode -> return RawDevice | otherwise -> return Stream }}} Another, far less desirable, alternative would be to add a new `IODeviceType` and call `ioe_unsupportedOperation` when you attempt to call `hIsSeekable` on such a device, but it only delays the unexpected bottom, and seems like it would rely on `seek` being implemented in a rather uniform manner across devices across platforms, which doesn't fit with my understanding of the world. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7985#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC