mirror of https://github.com/vitalif/phantomjs
Implement copyTree in filesystem-shim
parent
afe59b87dc
commit
bb1a6fa838
|
@ -102,6 +102,18 @@ window.fs.copy = function (source, destination) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Copy a directory tree.
|
||||||
|
* It will throw an exception if it fails.
|
||||||
|
*
|
||||||
|
* @param source Path of the source directory tree
|
||||||
|
* @param destination Path of the destination directory tree
|
||||||
|
*/
|
||||||
|
window.fs.copyTree = function (source, destination) {
|
||||||
|
if (!fs._copyTree(source, destination)) {
|
||||||
|
throw "Unable to copy directory tree '" + source + "' at '" + destination + "'";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Move a file.
|
/** Move a file.
|
||||||
* It will throw an exception if it fails.
|
* It will throw an exception if it fails.
|
||||||
*
|
*
|
|
@ -174,6 +174,15 @@ class FileSystem(QObject):
|
||||||
# Directories
|
# Directories
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot(str, str, result=bool)
|
||||||
|
def _copyTree(self, source, target):
|
||||||
|
try:
|
||||||
|
shutil.copytree(source, target)
|
||||||
|
return True
|
||||||
|
except IOError as (t, e):
|
||||||
|
qDebug("FileSystem.copyTree - %s: '%s' -> '%s'" % (e, source, target))
|
||||||
|
return False
|
||||||
|
|
||||||
@pyqtSlot(str, result=bool)
|
@pyqtSlot(str, result=bool)
|
||||||
def _removeDirectory(self, path):
|
def _removeDirectory(self, path):
|
||||||
try:
|
try:
|
||||||
|
@ -192,15 +201,6 @@ class FileSystem(QObject):
|
||||||
qDebug("FileSystem.removeTree - %s: '%s'" % (e, path))
|
qDebug("FileSystem.removeTree - %s: '%s'" % (e, path))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@pyqtSlot(str, str, result=bool)
|
|
||||||
def copyTree(self, source, target):
|
|
||||||
try:
|
|
||||||
shutil.copytree(source, target)
|
|
||||||
return True
|
|
||||||
except IOError as (t, e):
|
|
||||||
qDebug("FileSystem.copyTree - %s: '%s' -> '%s'" % (e, source, target))
|
|
||||||
return False
|
|
||||||
|
|
||||||
@pyqtSlot(str, str, result=bool)
|
@pyqtSlot(str, str, result=bool)
|
||||||
def copyLinkTree(self, source, target):
|
def copyLinkTree(self, source, target):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -85,7 +85,7 @@ class Phantom(QObject):
|
||||||
self.m_page.mainFrame().addToJavaScriptWindowObject('fs', self.m_filesystem)
|
self.m_page.mainFrame().addToJavaScriptWindowObject('fs', self.m_filesystem)
|
||||||
|
|
||||||
jsShims = (
|
jsShims = (
|
||||||
':/fs-shim.js',
|
':/filesystem-shim.js',
|
||||||
':/webpage-shim.js'
|
':/webpage-shim.js'
|
||||||
)
|
)
|
||||||
for shim in jsShims:
|
for shim in jsShims:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>configurator.js</file>
|
<file>configurator.js</file>
|
||||||
<file>fs-shim.js</file>
|
<file>filesystem-shim.js</file>
|
||||||
<file>webpage-shim.js</file>
|
<file>webpage-shim.js</file>
|
||||||
<file>resources/coffee-script.js</file>
|
<file>resources/coffee-script.js</file>
|
||||||
<file>resources/pyphantomjs-icon.png</file>
|
<file>resources/pyphantomjs-icon.png</file>
|
||||||
|
|
Loading…
Reference in New Issue