mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 12:47:59 +01:00
move LocalFile and fopen to a vimperator.io namespace
This commit is contained in:
@@ -254,7 +254,7 @@ vimperator.completion = (function() // {{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fd = vimperator.fopen(dir);
|
var fd = vimperator.io.fopen(dir);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,22 +27,27 @@ the provisions above, a recipient may use your version of this file under
|
|||||||
the terms of any one of the MPL, the GPL or the LGPL.
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
}}} ***** END LICENSE BLOCK *****/
|
}}} ***** END LICENSE BLOCK *****/
|
||||||
|
|
||||||
|
vimperator.io = {};
|
||||||
|
|
||||||
const PERM_IWOTH = 00002; /* write permission, others */
|
vimperator.io.fopen = function(path, mode, perms, tmp)
|
||||||
const PERM_IWGRP = 00020; /* write permission, group */
|
|
||||||
|
|
||||||
const MODE_RDONLY = 0x01;
|
|
||||||
const MODE_WRONLY = 0x02;
|
|
||||||
const MODE_RDWR = 0x04;
|
|
||||||
const MODE_CREATE = 0x08;
|
|
||||||
const MODE_APPEND = 0x10;
|
|
||||||
const MODE_TRUNCATE = 0x20;
|
|
||||||
const MODE_SYNC = 0x40;
|
|
||||||
const MODE_EXCL = 0x80;
|
|
||||||
|
|
||||||
|
|
||||||
function LocalFile(file, mode, perms, tmp) // {{{
|
|
||||||
{
|
{
|
||||||
|
return new vimperator.io.LocalFile(path, mode, perms, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
vimperator.io.LocalFile = function(file, mode, perms, tmp) // {{{
|
||||||
|
{
|
||||||
|
const PERM_IWOTH = 00002; /* write permission, others */
|
||||||
|
const PERM_IWGRP = 00020; /* write permission, group */
|
||||||
|
|
||||||
|
const MODE_RDONLY = 0x01;
|
||||||
|
const MODE_WRONLY = 0x02;
|
||||||
|
const MODE_RDWR = 0x04;
|
||||||
|
const MODE_CREATE = 0x08;
|
||||||
|
const MODE_APPEND = 0x10;
|
||||||
|
const MODE_TRUNCATE = 0x20;
|
||||||
|
const MODE_SYNC = 0x40;
|
||||||
|
const MODE_EXCL = 0x80;
|
||||||
|
|
||||||
const classes = Components.classes;
|
const classes = Components.classes;
|
||||||
const interfaces = Components.interfaces;
|
const interfaces = Components.interfaces;
|
||||||
|
|
||||||
@@ -116,7 +121,7 @@ function LocalFile(file, mode, perms, tmp) // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LocalFile.prototype.write =
|
vimperator.io.LocalFile.prototype.write =
|
||||||
function fo_write(buf)
|
function fo_write(buf)
|
||||||
{
|
{
|
||||||
if (!("outputStream" in this))
|
if (!("outputStream" in this))
|
||||||
@@ -125,7 +130,7 @@ function fo_write(buf)
|
|||||||
return this.outputStream.write(buf, buf.length);
|
return this.outputStream.write(buf, buf.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFile.prototype.read =
|
vimperator.io.LocalFile.prototype.read =
|
||||||
function fo_read(max)
|
function fo_read(max)
|
||||||
{
|
{
|
||||||
if (this.localFile.isDirectory())
|
if (this.localFile.isDirectory())
|
||||||
@@ -155,7 +160,7 @@ function fo_read(max)
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFile.prototype.close =
|
vimperator.io.LocalFile.prototype.close =
|
||||||
function fo_close()
|
function fo_close()
|
||||||
{
|
{
|
||||||
if ("outputStream" in this)
|
if ("outputStream" in this)
|
||||||
@@ -164,7 +169,7 @@ function fo_close()
|
|||||||
this.inputStream.close();
|
this.inputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalFile.prototype.flush =
|
vimperator.io.LocalFile.prototype.flush =
|
||||||
function fo_close()
|
function fo_close()
|
||||||
{
|
{
|
||||||
return this.outputStream.flush();
|
return this.outputStream.flush();
|
||||||
|
|||||||
@@ -951,7 +951,7 @@ function Mappings() //{{{
|
|||||||
if (url.match(/^file:\/\//) || url.match(/^\//))
|
if (url.match(/^file:\/\//) || url.match(/^\//))
|
||||||
{
|
{
|
||||||
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
|
||||||
var file = vimperator.fopen(stripedFilename, '<');
|
var file = vimperator.io.fopen(stripedFilename, '<');
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -269,11 +269,6 @@ const vimperator = (function() //{{{
|
|||||||
content.focus(); // FIXME: shouldn't be window.document.content?
|
content.focus(); // FIXME: shouldn't be window.document.content?
|
||||||
},
|
},
|
||||||
|
|
||||||
fopen: function(path, mode, perms, tmp)
|
|
||||||
{
|
|
||||||
return new LocalFile(path, mode, perms, tmp);
|
|
||||||
},
|
|
||||||
|
|
||||||
// partial sixth level expression evaluation
|
// partial sixth level expression evaluation
|
||||||
eval: function(string)
|
eval: function(string)
|
||||||
{
|
{
|
||||||
@@ -582,7 +577,7 @@ const vimperator = (function() //{{{
|
|||||||
if (input)
|
if (input)
|
||||||
{
|
{
|
||||||
filein = getTempFile();
|
filein = getTempFile();
|
||||||
var fdin = vimperator.fopen(filein, ">");
|
var fdin = vimperator.io.fopen(filein, ">");
|
||||||
fdin.write(input);
|
fdin.write(input);
|
||||||
fdin.close();
|
fdin.close();
|
||||||
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
|
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
|
||||||
@@ -594,7 +589,7 @@ const vimperator = (function() //{{{
|
|||||||
else
|
else
|
||||||
res = this.run("sh", ["-c", command], true);
|
res = this.run("sh", ["-c", command], true);
|
||||||
|
|
||||||
var fd = vimperator.fopen(fileout, "<");
|
var fd = vimperator.io.fopen(fileout, "<");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@@ -619,7 +614,7 @@ const vimperator = (function() //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fd = vimperator.fopen(filename, "<");
|
var fd = vimperator.io.fopen(filename, "<");
|
||||||
if (!fd)
|
if (!fd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -773,7 +768,7 @@ const vimperator = (function() //{{{
|
|||||||
|
|
||||||
if (plugin_dir)
|
if (plugin_dir)
|
||||||
{
|
{
|
||||||
var fd = vimperator.fopen(plugin_dir);
|
var fd = vimperator.io.fopen(plugin_dir);
|
||||||
var entries = fd.read();
|
var entries = fd.read();
|
||||||
fd.close();
|
fd.close();
|
||||||
vimperator.log("Sourcing plugin directory...", 3);
|
vimperator.log("Sourcing plugin directory...", 3);
|
||||||
|
|||||||
Reference in New Issue
Block a user