wdCopyMove method

Future<void> wdCopyMove(
  1. Client self,
  2. String oldPath,
  3. String newPath,
  4. bool isCopy,
  5. bool overwrite, {
  6. CancelToken? cancelToken,
})

COPY OR MOVE

Implementation

Future<void> wdCopyMove(
    Client self, String oldPath, String newPath, bool isCopy, bool overwrite,
    {CancelToken? cancelToken}) async {
  var method = isCopy == true ? 'COPY' : 'MOVE';
  var resp = await this.req(self, method, oldPath, optionsHandler: (options) {
    options.headers?['destination'] = Uri.encodeFull(join(self.uri, newPath));
    options.headers?['overwrite'] = overwrite == true ? 'T' : 'F';
  }, cancelToken: cancelToken);

  var status = resp.statusCode;
  // TODO 207
  if (status == 201 || status == 204 || status == 207) {
    return;
  } else if (status == 409) {
    await this._createParent(self, newPath, cancelToken: cancelToken);
    return this.wdCopyMove(self, oldPath, newPath, isCopy, overwrite,
        cancelToken: cancelToken);
  } else {
    throw newResponseError(resp);
  }
}