packages feed

hslua-module-zip 1.1.1 → 1.1.2

raw patch · 4 files changed

+41/−4 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ HsLua.Module.Zip: symlink :: LuaError e => DocumentedFunction e

Files

CHANGELOG.md view
@@ -2,6 +2,14 @@  `hslua-module-zips` uses [PVP Versioning][]. +## hslua-module-zip-1.1.2++Released 2024-05-05.++-   Added a `symlink` method to Entry objects. This allows to+    check whether an entry represents a symbolic link, and where+    it links.+ ## hslua-module-zip-1.1.1  Released 2024-01-18.
hslua-module-zip.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.2 name:                hslua-module-zip-version:             1.1.1+version:             1.1.2 synopsis:            Lua module to work with file zips. description:         Module with function for creating, modifying, and                      extracting files from zip archives.
src/HsLua/Module/Zip.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -28,6 +27,7 @@   , peekEntryFuzzy   -- ** entry methods   , contents+  , symlink   -- * Zip Options   , peekZipOptions   )@@ -36,7 +36,8 @@ import Prelude hiding (zip) import Control.Applicative (optional) import Control.Monad ((<$!>))-import Codec.Archive.Zip (Archive, Entry, ZipOption (..), emptyArchive)+import Codec.Archive.Zip+  ( Archive, Entry, ZipOption (..), emptyArchive, symbolicLinkEntryTarget ) import Data.Functor ((<&>)) import Data.Maybe (catMaybes, fromMaybe) import Data.Time.Clock.POSIX (getPOSIXTime)@@ -44,7 +45,7 @@ import HsLua.Core   ( LuaError, NumArgs (..), NumResults (..), Type(..), call, failLua   , fromStackIndex, getfield, gettop, replace, liftIO, ltype-  , nth, nthBottom, setmetatable )+  , nth, nthBottom, pushnil, setmetatable ) import HsLua.List (newListMetatable) import HsLua.Marshalling   ( Peeker, Pusher, choice, failPeek, liftLua, peekBool@@ -253,6 +254,7 @@     (pushIntegral, Zip.eLastModified)     (peekIntegral, \entry modtime -> entry { Zip.eLastModified = modtime})   , method contents+  , method symlink   ]  -- | Creates a new 'ZipEntry' from a file; wraps 'Zip.readEntry'.@@ -286,6 +288,18 @@      [ "Get the uncompressed contents of a zip entry. If `password` is given,"      , "then that password is used to decrypt the contents. An error is throws"      , "if decrypting fails."+     ]++-- | Returns the target if the Entry represents a symbolic link.+symlink :: LuaError e => DocumentedFunction e+symlink = defun "symlink"+  ### liftPure symbolicLinkEntryTarget+  <#> udparam typeEntry "self" ""+  =#> functionResult (maybe pushnil pushString) "string|nil"+        "link target if entry represents a symbolic link"+  #? T.unlines+     [ "Returns the target if the Entry represents a symbolic link,"+     , "and `nil` otherwise."      ]  peekEntryFuzzy :: LuaError e => Peeker e Entry
test/test-zip.lua view
@@ -172,6 +172,21 @@           )         end)       end)+    end),++    -- Can't reliably test this for actual symlinks, as Windows doesn't+    -- support them. Only the behavior for normal files is tested.+    test('has symlink function', function ()+      system.with_tmpdir('archive', function (tmpdir)+        system.with_wd(tmpdir, function ()+          local filename = 'greetings.txt'+          local fh = io.open(filename, 'w')+          fh:write('Hallo!\n')+          fh:close()+          local entry = zip.read_entry(filename)+          assert.is_nil(entry:symlink())+        end)+      end)     end)   },