title: Using ZIPFoundation, how to add a file to an archive at desired path?
body: <p>I'm trying to add a file to an archive in Swift using the ZIPFoundation lib.</p>
  <p>The archive looks like this:</p>
  <pre class="lang-none prettyprint-override"><code>/
  /folder1/
  /folder2/ &lt;-- Move file here.
  </code></pre>
  <p>Currently using this to add my file to the archive, but I don't get the logic of the parameters:</p>
  <pre class="lang-swift prettyprint-override"><code>public func addEntry(with path: String, relativeTo baseURL: URL)
  </code></pre>
  <p>Creating an <code>Archive</code> object and adding the file using <code>addEntry()</code>, is there a way to not just add the file to the root path of the archive?</p>
  <p>Code Edit:</p>
  <pre><code>internal func moveLicense(from licenseUrl: URL, to publicationUrl: URL) throws {
      guard let archive = Archive(url: publicationUrl, accessMode: .update) else  {
          return
      }
      // Create local folder to have the same path as in the archive.
      let fileManager = FileManager.default
      var urlMetaInf = licenseUrl.deletingLastPathComponent()
      
      urlMetaInf.appendPathComponent(&quot;META-INF&quot;, isDirectory: true)
      try fileManager.createDirectory(at: urlMetaInf, withIntermediateDirectories: true, attributes: nil)
      
      let uuu = URL(fileURLWithPath: urlMetaInf.path, isDirectory: true)
      // move license in the meta-inf folder.
      try fileManager.moveItem(at: licenseUrl, to: uuu.appendingPathComponent(&quot;license.lcpl&quot;))
      // move dir
      print(uuu.lastPathComponent.appending(&quot;/license.lcpl&quot;))
      print(uuu.deletingLastPathComponent())
      do {
      try archive.addEntry(with: uuu.lastPathComponent.appending(&quot;license.lcpl&quot;), // Missing '/' before license
                           relativeTo: uuu.deletingLastPathComponent())
      } catch {
          print(error)
      }
  }
  // This is still testing code, don't mind the names :)
  </code></pre>