Skip to content

Commit

Permalink
feat(Filesystem): Remove createIntermediateDirectories from MkdirOpti…
Browse files Browse the repository at this point in the history
…ons (#2410)
  • Loading branch information
jcesarmobile committed Feb 5, 2020
1 parent 7faec79 commit dae3510
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,6 @@ public void mkdir(PluginCall call) {
saveCall(call);
String path = call.getString("path");
String directory = getDirectoryParameter(call);
boolean intermediate = call.getBoolean("createIntermediateDirectories", false).booleanValue();
if (call.getBoolean("createIntermediateDirectories") != null) {
Log.w(getLogTag(),"createIntermediateDirectories is deprecated, use recursive");
}
boolean recursive = call.getBoolean("recursive", false).booleanValue();

File fileObject = getFileObject(path, directory);
Expand All @@ -342,7 +338,7 @@ public void mkdir(PluginCall call) {
if (!isPublicDirectory(directory)
|| isStoragePermissionGranted(PluginRequestCodes.FILESYSTEM_REQUEST_WRITE_FOLDER_PERMISSIONS, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
boolean created = false;
if (intermediate || recursive) {
if (recursive) {
created = fileObject.mkdirs();
} else {
created = fileObject.mkdir();
Expand Down
6 changes: 0 additions & 6 deletions core/src/core-plugin-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,6 @@ export interface MkdirOptions {
* The FilesystemDirectory to make the new directory in
*/
directory?: FilesystemDirectory;
/**
* @deprecated - use recursive
* Whether to create any missing parent directories as well
* Defaults to false
*/
createIntermediateDirectories?: boolean;
/**
* Whether to create any missing parent directories as well.
* Defaults to false
Expand Down
7 changes: 1 addition & 6 deletions core/src/web/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,7 @@ export class FilesystemPluginWeb extends WebPlugin implements FilesystemPlugin {
*/
async mkdir(options: MkdirOptions): Promise<MkdirResult> {
const path: string = this.getPath(options.directory, options.path);
const createIntermediateDirectories = options.createIntermediateDirectories;
if (options.createIntermediateDirectories !== undefined) {
console.warn('createIntermediateDirectories is deprecated, use recursive');
}
const recursive = options.recursive;
const doRecursive = (createIntermediateDirectories || recursive);
const doRecursive = options.recursive;
const parentPath = path.substr(0, path.lastIndexOf('/'));

let depth = (path.match(/\//g) || []).length;
Expand Down
5 changes: 1 addition & 4 deletions electron/src/electron/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ export class FilesystemPluginElectron extends WebPlugin implements FilesystemPlu
if(Object.keys(this.fileLocations).indexOf(options.directory) === -1)
reject(`${options.directory} is currently not supported in the Electron implementation.`);
let lookupPath = this.fileLocations[options.directory] + options.path;
if (options.createIntermediateDirectories !== undefined) {
console.warn('createIntermediateDirectories is deprecated, use recursive');
}
const doRecursive = options.createIntermediateDirectories || options.recursive;
const doRecursive = options.recursive;
this.NodeFS.mkdir(lookupPath, { recursive: doRecursive }, (err:any) => {
if(err) {
reject(err);
Expand Down
6 changes: 1 addition & 5 deletions ios/Capacitor/Capacitor/Plugins/Filesystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ public class CAPFilesystemPlugin : CAPPlugin {
return
}

let createIntermediateDirectories = call.get("createIntermediateDirectories", Bool.self, false)!
if let _ = call.get("createIntermediateDirectories", Bool.self) {
CAPLog.print("createIntermediateDirectories is deprecated, use recursive")
}
let recursive = call.get("recursive", Bool.self, false)!
let directoryOption = call.get("directory", String.self, DEFAULT_DIRECTORY)!
guard let fileUrl = getFileUrl(path, directoryOption) else {
Expand All @@ -234,7 +230,7 @@ public class CAPFilesystemPlugin : CAPPlugin {
}

do {
try FileManager.default.createDirectory(at: fileUrl, withIntermediateDirectories: createIntermediateDirectories || recursive, attributes: nil)
try FileManager.default.createDirectory(at: fileUrl, withIntermediateDirectories: recursive, attributes: nil)
call.success()
} catch let error as NSError {
handleError(call, error.localizedDescription, error)
Expand Down

0 comments on commit dae3510

Please sign in to comment.