2000-01-04 00:50:08 +00:00
|
|
|
const nsILocalFile = Components.interfaces.nsILocalFile;
|
|
|
|
var prefix = "";
|
|
|
|
|
2000-03-24 05:48:18 +00:00
|
|
|
function rename(source, newName)
|
|
|
|
{
|
|
|
|
try {
|
2000-09-13 23:57:52 +00:00
|
|
|
var sourceFile = Components.classes["@mozilla.org/file/local;1"].
|
2000-03-24 05:48:18 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-04 00:50:08 +00:00
|
|
|
function cp(source, dest, followLinks, newName)
|
|
|
|
{
|
|
|
|
try {
|
2000-09-13 23:57:52 +00:00
|
|
|
var sourceFile = Components.classes["@mozilla.org/file/local;1"].
|
2000-01-04 00:50:08 +00:00
|
|
|
createInstance(nsILocalFile);
|
|
|
|
sourceFile.initWithPath(source);
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
var destFile = Components.classes["@mozilla.org/file/local;1"].
|
2000-01-04 00:50:08 +00:00
|
|
|
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 {
|
2000-09-13 23:57:52 +00:00
|
|
|
var sourceFile = Components.classes["@mozilla.org/file/local;1"].
|
2000-01-04 00:50:08 +00:00
|
|
|
createInstance(nsILocalFile);
|
|
|
|
sourceFile.initWithPath(source);
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
var destFile = Components.classes["@mozilla.org/file/local;1"].
|
2000-01-04 00:50:08 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|