Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Fix. platform field supports values not only Windows/Unix.
Browse files Browse the repository at this point in the history
  • Loading branch information
moteus committed Mar 24, 2014
1 parent d316026 commit afd95fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Based on http://wiki.tcl.tk/15158
- bit32 or bit
- iconv (if not found then file names passed as is)
- alien/ffi (on Windos detect system default codepage)
- lunit (only for test)
- lunitx (only for test)
- [AesFileEncrypt] (https://github.com/moteus/lua-AesFileEncrypt) (optional)

## Supports ##
Expand All @@ -33,6 +33,7 @@ function make_reader(fname)
isdir = false,
mtime = 1348048902, -- lfs.attributes('modification')
exattrib = 32, -- get from GetFileAttributesA
platform = 'fat32', -- `exattrib` is platform dependent
}
return desc, desc.isfile and function()
local chunk = f:read(chunk_size)
Expand Down Expand Up @@ -88,7 +89,7 @@ ZipStream = ZipWriter.new{

```



[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/zipwriter/trend.png)](https://bitdeli.com/free "Bitdeli Badge")



[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/zipwriter/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

2 changes: 2 additions & 0 deletions lakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
J = J or path.join

if LUA_VER == '5.2' then
LUA_NEED = 'lua52'
LUA_DIR = ENV.LUA_DIR_5_2 or ENV.LUA_DIR
Expand Down
16 changes: 11 additions & 5 deletions lua/ZipWriter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ end
-- @tfield number ctime
-- @tfield number atime
-- @tfield number exattrib on Windows it can be result of GetFileAttributes
-- @tfield string platform
-- @tfield ?string data file content

---
Expand Down Expand Up @@ -637,13 +638,18 @@ function ZipWriter:write(
if use_aes then
ver_made = ZIP_VERSION_EXTRACT["6.3"] -- @encrypt 7z do this
else
ver_made = IS_WINDOWS and ZIP_VERSION_EXTRACT["2.0"] or ZIP_VERSION_EXTRACT["2.0"]
ver_made = ZIP_VERSION_EXTRACT["2.0"]
end
local made_by_win
if not fileDesc.platform then made_by_win = IS_WINDOWS
else made_by_win = (fileDesc.platform:lower() == 'windows') end

ver_made = bit.bor( ver_made, made_by_win and ZIP_VERSION_MADE.FAT32 or ZIP_VERSION_MADE.UNIX )
local platform_made = fileDesc.platform
if not platform_made then
platform_made = IS_WINDOWS and 'fat32' or 'unix'
elseif platform_made:lower() == 'windows' then
platform_made = 'fat32' -- for compatability
end
platform_made = ZIP_VERSION_MADE[platform_made:upper()] or ZIP_VERSION_MADE.UNIX

ver_made = bit.bor( ver_made, platform_made )

if fileDesc.isfile then
flags = bit.bor(flags, level.flag)
Expand Down

0 comments on commit afd95fc

Please sign in to comment.