summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-08-01 22:13:07 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-08-01 22:13:07 +0000
commitbd788d5972dc5d1896820740061bbc9250d80682 (patch)
tree650153daac57fef9cfa2a07a8cb6ae8d1829d8d5
parent3a4235b39c68512f78ab93c9e0cc05b3588c07d5 (diff)
downloadpygobject-bd788d5972dc5d1896820740061bbc9250d80682.tar.gz
pygobject-bd788d5972dc5d1896820740061bbc9250d80682.tar.xz
pygobject-bd788d5972dc5d1896820740061bbc9250d80682.zip
Wrap gio.File.move
2008-08-02 Johan Dahlin <johan@gnome.org> * gio/gio.defs: * gio/gfile.override: * tests/test_gio.py: Wrap gio.File.move svn path=/trunk/; revision=908
-rw-r--r--ChangeLog7
-rw-r--r--gio/gio.defs39
-rw-r--r--tests/test_gio.py30
3 files changed, 75 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e86cf4c..b129dfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-08-02 Johan Dahlin <johan@gnome.org>
+ * gio/gio.defs:
+ * gio/gfile.override:
+ * tests/test_gio.py:
+ Wrap gio.File.move
+
+2008-08-02 Johan Dahlin <johan@gnome.org>
+
* gio/Makefile.am:
* gio/gfile.override:
* gio/gio.defs:
diff --git a/gio/gio.defs b/gio/gio.defs
index c1d1f7b..dbd0f63 100644
--- a/gio/gio.defs
+++ b/gio/gio.defs
@@ -1723,6 +1723,45 @@
)
(define-method move
+ (docstring
+"Tries to move the file or directory source to the location\n"
+"specified by destination. If native move operations are\n"
+"supported then this is used, otherwise a copy + delete fallback\n"
+"is used. The native implementation may support moving directories\n"
+"(for instance on moves inside the same filesystem), but the \n"
+"fallback code does not.\n"
+"\n"
+"If the flag gio.FILE_COPY_OVERWRITE is specified an already existing\n"
+"destination file is overwritten.\n"
+"\n"
+"If the flag gio.FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlink\n"
+"will be copied as symlinks, otherwise the target of the source symlink\n"
+"will be copied.\n"
+"\n"
+"If cancellable is not None, then the operation can be cancelled b\n"
+"triggering the cancellable object from another thread.\n"
+"If the operation was cancelled, the error gio.ERROR_CANCELLED\n"
+"will be returned.\n"
+"\n"
+"If progress_callback is not None, then the operation can be monitored\n"
+"by setting this to a callable. if specified progress_callback_data will\n"
+"be passed to this function. It is guaranteed that this callback\n"
+"will be called after all data has been transferred with the total number\n"
+"of bytes copied during the operation.\n"
+"\n"
+"If the source file does not exist then the gio.ERROR_NOT_FOUND\n"
+"error is returned, independent on the status of the destination.\n"
+"\n"
+"If gio.FILE_COPY_OVERWRITE is not specified and the target exists\n"
+"then the error gio.ERROR_EXISTS is returned.\n"
+"\n"
+"If trying to overwrite a file over a directory the gio.ERROR_IS_DIRECTORY\n"
+"error is returned. If trying to overwrite a directory with a directory\n"
+"the gio.ERROR_WOULD_MERGE error is returned.\n"
+"\n"
+"If the source is a directory and the target does not exist\n"
+"or gio.FILE_COPY_OVERWRITE is specified and the target is a file\n"
+"then the gio.ERROR_WOULD_RECURSE error is returned.")
(of-object "GFile")
(c-name "g_file_move")
(return-type "gboolean")
diff --git a/tests/test_gio.py b/tests/test_gio.py
index d4054de..5a3715b 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -13,7 +13,8 @@ class TestFile(unittest.TestCase):
def tearDown(self):
self._f.close()
- os.unlink("file.txt")
+ if os.path.exists('file.txt'):
+ os.unlink("file.txt")
def testReadAsync(self):
self._f.write("testing")
@@ -159,6 +160,33 @@ class TestFile(unittest.TestCase):
finally:
os.unlink("copy.txt")
+ def testMove(self):
+ if os.path.exists('move.txt'):
+ os.unlink("move.txt")
+
+ source = gio.File('file.txt')
+ destination = gio.File('move.txt')
+ retval = source.move(destination)
+ self.failUnless(retval)
+
+ self.failIf(os.path.exists('file.txt'))
+ self.failUnless(os.path.exists('move.txt'))
+
+ self.called = False
+ def callback(current, total):
+ self.called = True
+ source = gio.File('move.txt')
+ destination = gio.File('move-2.txt')
+ try:
+ retval = source.move(destination, callback)
+ self.failUnless(retval)
+
+ self.failIf(os.path.exists('move.txt'))
+ self.failUnless(os.path.exists('move-2.txt'))
+ self.failUnless(self.called)
+ finally:
+ os.unlink("move-2.txt")
+
def testInfoList(self):
infolist = self.file.query_settable_attributes()
for info in infolist: