Skip to content

Commit 82639b1

Browse files
committed
Add @SInCE annotation
1 parent 615ba10 commit 82639b1

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

System/Posix/Directory/Common.hsc

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
module System.Posix.Directory.Common (
2222
DirStream(..),
2323
CDir,
24+
CDirent,
25+
DirStreamOffset(..),
26+
2427
DirStreamWithPath(..),
2528
fromDirStreamWithPath,
2629
toDirStreamWithPath,
27-
2830
DirEnt(..),
29-
CDirent,
3031
dirEntName,
3132
dirEntType,
3233
DirType( DirType
@@ -40,15 +41,20 @@ module System.Posix.Directory.Common (
4041
, SocketType
4142
, WhiteoutType
4243
),
43-
isUnknownType, isBlockDeviceType, isCharacterDeviceType, isNamedPipeType,
44-
isRegularFileType, isDirectoryType, isSymbolicLinkType, isSocketType,
44+
isUnknownType,
45+
isNamedPipeType,
46+
isCharacterDeviceType,
47+
isDirectoryType,
48+
isBlockDeviceType,
49+
isRegularFileType,
50+
isSymbolicLinkType,
51+
isSocketType,
4552
isWhiteoutType,
4653
getRealDirType,
4754
unsafeOpenDirStreamFd,
4855
readDirStreamWith,
4956
readDirStreamWithPtr,
5057

51-
DirStreamOffset(..),
5258
rewindDirStream,
5359
closeDirStream,
5460
#ifdef HAVE_SEEKDIR
@@ -75,22 +81,28 @@ import System.Posix.Files.Common
7581

7682
newtype DirStream = DirStream (Ptr CDir)
7783

84+
-- | @since 2.8.6.0
7885
newtype DirStreamWithPath a = DirStreamWithPath (a, Ptr CDir)
7986

8087
-- | Convert a 'DirStreamWithPath' to a 'DirStream'.
8188
-- Note that the underlying pointer is shared by both values, hence any
8289
-- modification to the resulting 'DirStream' will also modify the original
8390
-- 'DirStreamWithPath'.
91+
--
92+
-- @since 2.8.6.0
8493
fromDirStreamWithPath :: DirStreamWithPath a -> DirStream
8594
fromDirStreamWithPath (DirStreamWithPath (_, ptr)) = DirStream ptr
8695

8796
-- | Construct a 'DirStreamWithPath' from a 'DirStream'.
8897
-- Note that the underlying pointer is shared by both values, hence any
8998
-- modification to the pointer of the resulting 'DirStreamWithPath' will also
9099
-- modify the original 'DirStream'.
100+
--
101+
-- @since 2.8.6.0
91102
toDirStreamWithPath :: a -> DirStream -> DirStreamWithPath a
92103
toDirStreamWithPath path (DirStream ptr) = DirStreamWithPath (path, ptr)
93104

105+
-- | @since 2.8.6.0
94106
newtype DirEnt = DirEnt (Ptr CDirent)
95107

96108
-- We provide a hand-written instance here since GeneralizedNewtypeDeriving and
@@ -126,6 +138,8 @@ data {-# CTYPE "struct dirent" #-} CDirent
126138
-- synonyms of this type may not be provided by the underlying platform. In that
127139
-- case none of those patterns will match and the application must handle that
128140
-- case accordingly.
141+
--
142+
-- @since 2.8.6.0
129143
newtype DirType = DirType CChar
130144
deriving (Eq, Ord, Show)
131145

@@ -166,22 +180,40 @@ pattern WhiteoutType :: DirType
166180
pattern WhiteoutType = DirType (CONST_DT_WHT)
167181

168182
-- | Checks if this 'DirType' refers to an entry of unknown type.
183+
--
184+
-- @since 2.8.6.0
169185
isUnknownType :: DirType -> Bool
170186
-- | Checks if this 'DirType' refers to a block device entry.
187+
--
188+
-- @since 2.8.6.0
171189
isBlockDeviceType :: DirType -> Bool
172190
-- | Checks if this 'DirType' refers to a character device entry.
191+
--
192+
-- @since 2.8.6.0
173193
isCharacterDeviceType :: DirType -> Bool
174194
-- | Checks if this 'DirType' refers to a named pipe entry.
195+
--
196+
-- @since 2.8.6.0
175197
isNamedPipeType :: DirType -> Bool
176198
-- | Checks if this 'DirType' refers to a regular file entry.
199+
--
200+
-- @since 2.8.6.0
177201
isRegularFileType :: DirType -> Bool
178202
-- | Checks if this 'DirType' refers to a directory entry.
203+
--
204+
-- @since 2.8.6.0
179205
isDirectoryType :: DirType -> Bool
180206
-- | Checks if this 'DirType' refers to a symbolic link entry.
207+
--
208+
-- @since 2.8.6.0
181209
isSymbolicLinkType :: DirType -> Bool
182210
-- | Checks if this 'DirType' refers to a socket entry.
211+
--
212+
-- @since 2.8.6.0
183213
isSocketType :: DirType -> Bool
184214
-- | Checks if this 'DirType' refers to a whiteout entry.
215+
--
216+
-- @since 2.8.6.0
185217
isWhiteoutType :: DirType -> Bool
186218

187219
isUnknownType dtype = dtype == UnknownType
@@ -194,6 +226,7 @@ isSymbolicLinkType dtype = dtype == SymbolicLinkType
194226
isSocketType dtype = dtype == SocketType
195227
isWhiteoutType dtype = dtype == WhiteoutType
196228

229+
-- | @since 2.8.6.0
197230
getRealDirType :: IO FileStatus -> DirType -> IO DirType
198231
getRealDirType _ BlockDeviceType = return BlockDeviceType
199232
getRealDirType _ CharacterDeviceType = return CharacterDeviceType
@@ -225,6 +258,8 @@ getRealDirType getFileStatus _ = do
225258
--
226259
-- The input file descriptor must not have been used with @threadWaitRead@ or
227260
-- @threadWaitWrite@.
261+
--
262+
-- @since 2.8.6.0
228263
unsafeOpenDirStreamFd :: Fd -> IO DirStream
229264
unsafeOpenDirStreamFd (Fd fd) = mask_ $ do
230265
ptr <- c_fdopendir fd
@@ -257,6 +292,8 @@ foreign import capi unsafe "dirent.h fdopendir"
257292
-- __NOTE:__ The lifetime of the pointer wrapped in the `DirEnt` is limited to
258293
-- invocation of the callback and it will be freed automatically after. Do not
259294
-- pass it to the outside world!
295+
--
296+
-- @since 2.8.6.0
260297
readDirStreamWith :: (DirEnt -> IO a) -> DirStream -> IO (Maybe a)
261298
readDirStreamWith f dstream = alloca
262299
(\ptr_dEnt -> readDirStreamWithPtr ptr_dEnt f dstream)
@@ -270,6 +307,8 @@ readDirStreamWith f dstream = alloca
270307
-- call of these functions.
271308
--
272309
-- __NOTE__: You are responsible for releasing the pointer after you are done.
310+
--
311+
-- @since 2.8.6.0
273312
readDirStreamWithPtr :: Ptr DirEnt -> (DirEnt -> IO a) -> DirStream -> IO (Maybe a)
274313
readDirStreamWithPtr ptr_dEnt f dstream@(DirStream dirp) = do
275314
resetErrno
@@ -291,12 +330,14 @@ readDirStreamWithPtr ptr_dEnt f dstream@(DirStream dirp) = do
291330
then return Nothing
292331
else throwErrno "readDirStream"
293332

333+
-- | @since 2.8.6.0
294334
dirEntName :: DirEnt -> IO CString
295335
dirEntName (DirEnt dEntPtr) = d_name dEntPtr
296336

297337
foreign import ccall unsafe "__hscore_d_name"
298338
d_name :: Ptr CDirent -> IO CString
299339

340+
-- | @since 2.8.6.0
300341
dirEntType :: DirEnt -> IO DirType
301342
dirEntType (DirEnt dEntPtr) = DirType <$> d_type dEntPtr
302343

System/Posix/Directory/Internals.hsc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
module System.Posix.Directory.Internals (
1616
DirStream(..),
1717
CDir,
18+
CDirent,
19+
DirStreamOffset(..),
20+
1821
DirStreamWithPath(..),
1922
fromDirStreamWithPath,
2023
toDirStreamWithPath,
2124
DirEnt(..),
22-
CDirent,
2325
dirEntName,
2426
dirEntType,
2527
DirType( DirType
@@ -45,7 +47,6 @@ module System.Posix.Directory.Internals (
4547
getRealDirType,
4648
readDirStreamWith,
4749
readDirStreamWithPtr,
48-
DirStreamOffset(..),
4950
) where
5051

5152
import System.Posix.Directory.Common

0 commit comments

Comments
 (0)