Skip to content

Commit

Permalink
fix for 32 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
guzba committed Aug 26, 2024
1 parent 1b02266 commit aaf3fde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/zippy/internal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ const
16.uint8, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
]

S_IFDIR* = 0o0040000
TUREAD* = 0o00400 # read by owner */
TUWRITE* = 0o00200 # write by owner */
TUEXEC* = 0o00100 # execute/search by owner */
TGREAD* = 0o00040 # read by group */
TGWRITE* = 0o00020 # write by group */
TGEXEC* = 0o00010 # execute/search by group */
TOREAD* = 0o00004 # read by other */
TOWRITE* = 0o00002 # write by other */
TOEXEC* = 0o00001 # execute/search by other */
S_IFDIR* = 0o0040000'u32
TUREAD* = 0o00400'u32 # read by owner */
TUWRITE* = 0o00200'u32 # write by owner */
TUEXEC* = 0o00100'u32 # execute/search by owner */
TGREAD* = 0o00040'u32 # read by group */
TGWRITE* = 0o00020'u32 # write by group */
TGEXEC* = 0o00010'u32 # execute/search by group */
TOREAD* = 0o00004'u32 # read by other */
TOWRITE* = 0o00002'u32 # write by other */
TOEXEC* = 0o00001'u32 # execute/search by other */

type
CompressionConfig* = object
Expand Down Expand Up @@ -272,7 +272,7 @@ proc determineMatchLength*(
proc toUnixPath*(path: string): string =
path.replace('\\', '/')

proc parseFilePermissions*(permissions: int): set[FilePermission] =
proc parseFilePermissions*(permissions: uint32): set[FilePermission] =
if defined(windows) or permissions == 0:
# Ignore file permissions on Windows. If they are absent (.zip made on
# Windows for example), set default permissions.
Expand Down
5 changes: 4 additions & 1 deletion src/zippy/tarballs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ proc extractAll*(
dest / path,
uncompressed.toOpenArray(pos, max(pos + size - 1, 0))
)
setFilePermissions(dest / path, parseFilePermissions(mode))
setFilePermissions(
dest / path,
parseFilePermissions(cast[uint32](mode))
)
lastModifiedTimes.add (path, initTime(mtime, 0))
elif typeflag == '5': # Directories
createDir(dest / path)
Expand Down
2 changes: 1 addition & 1 deletion src/zippy/tarballs_v1.nim
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ proc openStreamImpl(
kind: ekNormalFile,
contents: data[pos ..< pos + fileSize],
lastModified: initTime(lastModified, 0),
permissions: parseFilePermissions(fileMode),
permissions: parseFilePermissions(cast[uint32](fileMode)),
)
elif typeFlag == '5':
tarball.contents[(fileNamePrefix / fileName).toUnixPath()] =
Expand Down
2 changes: 1 addition & 1 deletion src/zippy/ziparchives.nim
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ proc openZipArchive*(
compressedSize: compressedSize,
uncompressedSize: uncompressedSize,
uncompressedCrc32: uncompressedCrc32,
filePermissions: parseFilePermissions((externalFileAttr.uint shr 16).int)
filePermissions: parseFilePermissions(externalFileAttr shr 16)
)
except IOError as e:
result.close()
Expand Down

0 comments on commit aaf3fde

Please sign in to comment.