You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/11/27 03:07:31 UTC

[24/30] git commit: Fix issue CB-339 duplicate of WP7 issue.

Fix issue CB-339 duplicate of WP7 issue.

Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/8d4fa8f7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/8d4fa8f7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/8d4fa8f7

Branch: refs/heads/master
Commit: 8d4fa8f79efea37b921de2bfecc957872539ad42
Parents: e7914cb
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Nov 8 17:11:41 2012 -0800
Committer: Ruslan Kokorev <ru...@bsquare.com>
Committed: Fri Nov 9 15:09:04 2012 +0400

----------------------------------------------------------------------
 templates/standalone/cordovalib/Commands/File.cs |   18 ++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/8d4fa8f7/templates/standalone/cordovalib/Commands/File.cs
----------------------------------------------------------------------
diff --git a/templates/standalone/cordovalib/Commands/File.cs b/templates/standalone/cordovalib/Commands/File.cs
index ca3357c..0a0efa1 100644
--- a/templates/standalone/cordovalib/Commands/File.cs
+++ b/templates/standalone/cordovalib/Commands/File.cs
@@ -1401,7 +1401,6 @@ namespace WPCordovaClassLib.Cordova.Commands
             }
         }
 
-        // TODO: this is NOT working, object is not valid ...
         private void GetFileOrDirectory(string options, bool getDirectory)
         {
             FileOptions fOptions = new FileOptions();
@@ -1459,6 +1458,23 @@ namespace WPCordovaClassLib.Cordova.Commands
                             return;
                         }
 
+
+                        // need to make sure the parent exists
+                        // it is an error to create a directory whose immediate parent does not yet exist
+			// see issue: https://issues.apache.org/jira/browse/CB-339
+                        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);