mkdirAll method

Future<void> mkdirAll(
  1. String path, [
  2. CancelToken? cancelToken
])

Recursively create folders

Implementation

Future<void> mkdirAll(String path, [CancelToken? cancelToken]) async {
  path = fixSlashes(path);
  var resp = await this.c.wdMkcol(this, path, cancelToken: cancelToken);
  var status = resp.statusCode;
  if (status == 201 || status == 405) {
    return;
  } else if (status == 409) {
    var paths = path.split('/');
    var sub = '/';
    for (var e in paths) {
      if (e == '') {
        continue;
      }
      sub += e + '/';
      resp = await this.c.wdMkcol(this, sub, cancelToken: cancelToken);
      status = resp.statusCode;
      if (status != 201 && status != 405) {
        throw newResponseError(resp);
      }
    }
    return;
  }
  throw newResponseError(resp);
}