summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/xpcom/tests/utils/cp.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:49:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:49:04 +0000
commit16f504a9dca3fe3b70568f67b7d41241ae485288 (patch)
treec60f36ada0496ba928b7161059ba5ab1ab224f9d /src/libs/xpcom18a4/xpcom/tests/utils/cp.js
parentInitial commit. (diff)
downloadvirtualbox-16f504a9dca3fe3b70568f67b7d41241ae485288.tar.xz
virtualbox-16f504a9dca3fe3b70568f67b7d41241ae485288.zip
Adding upstream version 7.0.6-dfsg.upstream/7.0.6-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/xpcom18a4/xpcom/tests/utils/cp.js')
-rw-r--r--src/libs/xpcom18a4/xpcom/tests/utils/cp.js111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/libs/xpcom18a4/xpcom/tests/utils/cp.js b/src/libs/xpcom18a4/xpcom/tests/utils/cp.js
new file mode 100644
index 00000000..a38c120b
--- /dev/null
+++ b/src/libs/xpcom18a4/xpcom/tests/utils/cp.js
@@ -0,0 +1,111 @@
+const nsILocalFile = Components.interfaces.nsILocalFile;
+var prefix = "";
+
+function rename(source, newName)
+{
+ try {
+ var sourceFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(nsILocalFile);
+ sourceFile.initWithPath(source);
+
+ }
+ catch (e) {
+ dump("Could not create nsILocalFile\n");
+ }
+
+
+ try {
+ sourceFile.copyTo(null, newName);
+ }
+ catch (e) {
+ dump("error coping" + e + "\n");
+ }
+}
+
+
+function cp(source, dest, followLinks, newName)
+{
+ try {
+ var sourceFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(nsILocalFile);
+ sourceFile.initWithPath(source);
+
+ var destFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(nsILocalFile);
+ destFile.initWithPath(dest);
+
+ }
+ catch (e) {
+ dump("Could not create nsILocalFile\n");
+ }
+
+ try {
+
+ if (! destFile.isDirectory())
+ {
+ dump("destination not a directory!\n");
+ return;
+ }
+ }
+ catch (e) {
+ dump("error accessing dest");
+ }
+
+ try {
+ if (followLinks)
+ {
+ sourceFile.copyToFollowingLinks(destFile, newName);
+ }
+ else
+ {
+ sourceFile.copyTo(destFile, newName);
+ }
+ }
+ catch (e) {
+ dump("error coping" + e + "\n");
+ }
+}
+
+
+function mv(source, dest, followLinks, newName)
+{
+ try {
+ var sourceFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(nsILocalFile);
+ sourceFile.initWithPath(source);
+
+ var destFile = Components.classes["@mozilla.org/file/local;1"].
+ createInstance(nsILocalFile);
+ destFile.initWithPath(dest);
+
+ }
+ catch (e) {
+ dump("Could not create nsILocalFile\n");
+ }
+
+ try {
+
+ if (! destFile.isDirectory())
+ {
+ dump("destination not a directory!\n");
+ return;
+ }
+ }
+ catch (e) {
+ dump("error accessing dest");
+ }
+
+ try {
+ if (followLinks)
+ {
+ sourceFile.moveToFollowingLinks(destFile, newName);
+ }
+ else
+ {
+ sourceFile.moveTo(destFile, newName);
+ }
+ }
+ catch (e) {
+ dump("error coping" + e + "\n");
+ }
+}