Skip to content

write content directly into zip archive #71

@bung87

Description

@bung87

Hi, I was trying to do something like code below
Thanks for putting effort in this project.

proc addFile*(
  archive: ZipArchive, content: string, path: string
) {.raises: [IOError, OSError, ZippyError].} =
  ## Adds a single file to the archive.

  let (head, tail) = splitPath(path)
  if head.len > 0 and head notin archive.contents:
    archive.contents[(head & os.DirSep).toUnixPath()] =
      ArchiveEntry(kind: ekDirectory)
  archive.contents[path.toUnixPath()] = ArchiveEntry(
    kind: ekFile,
    contents: content,
    lastModified: getTime(),
    permissions: {},
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions