Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / xwalk / app / tools / android / util.py
index ed90122..99c0aa3 100644 (file)
@@ -49,3 +49,23 @@ def GetVersion(path):
   version_str += ('.').join(version_nums)
   file_handle.close()
   return version_str
+
+
+def CreateAndCopyDir(src_dir, dest_dir, delete_if_exists=False):
+  if not os.path.isdir(src_dir):
+    return False
+  # create path, except last directory (handled by copytree)
+  pre_dest_dir = os.path.dirname(dest_dir)
+  if not os.path.isdir(pre_dest_dir):
+    try:
+      os.makedirs(pre_dest_dir)  # throws exception on error
+    except OSError:
+      return False
+  if os.path.exists(dest_dir):
+    if delete_if_exists:
+      shutil.rmtree(dest_dir)
+    else:
+      return False
+  shutil.copytree(src_dir, dest_dir)
+  return True
+