16
16
-----------------------------------------------------------------------------
17
17
module Codec.Archive.Tar.Types (
18
18
19
- Entry (.. ),
19
+ GenEntry (.. ),
20
+ Entry ,
20
21
entryPath ,
21
- EntryContent (.. ),
22
+ GenEntryContent (.. ),
23
+ EntryContent ,
22
24
FileSize ,
23
25
Permissions ,
24
26
Ownership (.. ),
@@ -99,15 +101,16 @@ type Permissions = FileMode
99
101
100
102
-- | Tar archive entry.
101
103
--
102
- data Entry = Entry {
104
+ -- @since 0.6.0.0
105
+ data GenEntry tarPath linkTarget = Entry {
103
106
104
107
-- | The path of the file or directory within the archive. This is in a
105
108
-- tar-specific form. Use 'entryPath' to get a native 'FilePath'.
106
- entryTarPath :: {-# UNPACK #-} ! TarPath ,
109
+ entryTarPath :: ! tarPath ,
107
110
108
111
-- | The real content of the entry. For 'NormalFile' this includes the
109
112
-- file data. An entry usually contains a 'NormalFile' or a 'Directory'.
110
- entryContent :: ! EntryContent ,
113
+ entryContent :: ! ( GenEntryContent linkTarget ) ,
111
114
112
115
-- | File permissions (Unix style file mode).
113
116
entryPermissions :: {-# UNPACK #-} ! Permissions ,
@@ -123,6 +126,8 @@ data Entry = Entry {
123
126
}
124
127
deriving (Eq , Show )
125
128
129
+ type Entry = GenEntry TarPath LinkTarget
130
+
126
131
-- | Native 'FilePath' of the file or directory within the archive.
127
132
--
128
133
entryPath :: Entry -> FilePath
@@ -132,18 +137,22 @@ entryPath = fromTarPath . entryTarPath
132
137
--
133
138
-- Portable archives should contain only 'NormalFile' and 'Directory'.
134
139
--
135
- data EntryContent = NormalFile LBS. ByteString {- # UNPACK #-} !FileSize
136
- | Directory
137
- | SymbolicLink ! LinkTarget
138
- | HardLink ! LinkTarget
139
- | CharacterDevice {- # UNPACK #-} !DevMajor
140
- {- # UNPACK #-} !DevMinor
141
- | BlockDevice {- # UNPACK #-} !DevMajor
142
- {- # UNPACK #-} !DevMinor
143
- | NamedPipe
144
- | OtherEntryType {- # UNPACK #-} !TypeCode LBS. ByteString
145
- {- # UNPACK #-} !FileSize
146
- deriving (Eq , Ord , Show )
140
+ -- @since 0.6.0.0
141
+ data GenEntryContent linkTarget
142
+ = NormalFile LBS. ByteString {- # UNPACK #-} !FileSize
143
+ | Directory
144
+ | SymbolicLink ! linkTarget
145
+ | HardLink ! linkTarget
146
+ | CharacterDevice {- # UNPACK #-} !DevMajor
147
+ {- # UNPACK #-} !DevMinor
148
+ | BlockDevice {- # UNPACK #-} !DevMajor
149
+ {- # UNPACK #-} !DevMinor
150
+ | NamedPipe
151
+ | OtherEntryType {- # UNPACK #-} !TypeCode LBS. ByteString
152
+ {- # UNPACK #-} !FileSize
153
+ deriving (Eq , Ord , Show )
154
+
155
+ type EntryContent = GenEntryContent LinkTarget
147
156
148
157
data Ownership = Ownership {
149
158
-- | The owner user name. Should be set to @\"\"@ if unknown.
@@ -183,10 +192,10 @@ data Format =
183
192
| GnuFormat
184
193
deriving (Eq , Ord , Show )
185
194
186
- instance NFData Entry where
195
+ instance NFData ( GenEntry a b ) where
187
196
rnf (Entry _ c _ _ _ _) = rnf c
188
197
189
- instance NFData EntryContent where
198
+ instance NFData ( GenEntryContent linkTarget ) where
190
199
rnf x = case x of
191
200
NormalFile c _ -> rnf c
192
201
OtherEntryType _ c _ -> rnf c
0 commit comments