Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[CB-339] Should not be able to create a file or directory if the pare…

…nt directory does not exist.
  • Loading branch information...
commit 79792880b12574dda080c5f24c5f5bf8f3223ce6 1 parent d805058
Jesse MacFadyen purplecabbage authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 templates/standalone/cordovalib/Commands/File.cs
15 templates/standalone/cordovalib/Commands/File.cs
View
@@ -1406,6 +1406,21 @@ private void GetFileOrDirectory(string options, bool getDirectory)
return;
}
+ // need to make sure the parent exists
+ // it is an error to create a directory whose immediate parent does not yet exist
+ string[] pathParts = path.Split('/');
+ string builtPath = pathParts[0];
+ for (int n = 1; n < pathParts.Length - 1; n++)
+ {
+ builtPath += "/" + pathParts[n];
+ if (!isoFile.DirectoryExists(builtPath))
+ {
+ Debug.WriteLine(String.Format("Error :: Parent folder \"{0}\" does not exist, when attempting to create \"{1}\"",builtPath,path));
+ DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, NOT_FOUND_ERR));
+ return;
+ }
+ }
+
if ((getDirectory) && (!isDirectory))
{
isoFile.CreateDirectory(path);
Please sign in to comment.
Something went wrong with that request. Please try again.