Skip to content

Commit

Permalink
fix #2: normalize path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
yxnan committed Feb 21, 2024
1 parent 5c5799f commit bf193d8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
stack:
name: stack / ${{ matrix.os }} / ghc ${{ matrix.ghc }}
permissions:
contents: write
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to the

## [Unreleased]

## [0.2.2] - 2024-02-22

### Fixed

- Normalize path separator to Unix format (issue #2)

## [0.2.1] - 2023-06-12

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion nekofs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: nekofs
version: 0.2.1
version: 0.2.2
synopsis: Create and extract nekodata files
description: Please see the README on GitHub at <https://github.com/yxnan/nekofs#readme>
category: CLI
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: nekofs
version: 0.2.1
version: 0.2.2
github: "yxnan/nekofs"
license: BSD3
author: "yxnan"
Expand Down
6 changes: 4 additions & 2 deletions src/NekoFS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ extractNeko nekofile outputDir verify = openBinaryFile nekofile ReadMode
B.hPut hOut block'
extract' hOut bs

normalizePathSep :: FilePath -> FilePath
normalizePathSep = map (\c -> if c == '\\' then '/' else c) -- issue #2

-- | Create a nekodata file from directory
createNeko :: FilePath -- ^ the directory to be packed into a nekofile
Expand Down Expand Up @@ -106,7 +108,7 @@ createNeko sourceDir outputFile = do
S.adler32 (mempty :: ByteString), 0, [])
let qOffset = if null acc then 25 -- ^ size of nekofsHeader
else getCurrentOffset (head acc)
file' = makeRelative sourceDir file -- to InternalPath
file' = normalizePathSep $ makeRelative sourceDir file -- to InternalPath
return (Q file' sz csz crc crcOrig adler qOffset bcnt bszL : acc)
where
getCurrentOffset = (+) <$> compressedSizeQ <*> offsetQ
Expand Down Expand Up @@ -149,7 +151,7 @@ generateMeta path = do
let metafile = dir </> "files.meta"
meta <- withCurrentDirectory dir $
find always (fileType ==? RegularFile) "."
>>= makeFilesMeta' . map (makeRelative ".")
>>= makeFilesMeta' . map (normalizePathSep . makeRelative ".")
B.writeFile metafile meta


0 comments on commit bf193d8

Please sign in to comment.