1
0
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:
Doug Kearns
2007-10-16 01:53:37 +00:00
parent 5eb7d90013
commit 70a4dff190
4 changed files with 29 additions and 29 deletions

View File

@@ -254,7 +254,7 @@ vimperator.completion = (function() // {{{
try
{
var fd = vimperator.fopen(dir);
var fd = vimperator.io.fopen(dir);
}
catch (e)
{

View File

@@ -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.
}}} ***** END LICENSE BLOCK *****/
vimperator.io = {};
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;
function LocalFile(file, mode, perms, tmp) // {{{
vimperator.io.fopen = function(path, 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 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)
{
if (!("outputStream" in this))
@@ -125,7 +130,7 @@ function fo_write(buf)
return this.outputStream.write(buf, buf.length);
}
LocalFile.prototype.read =
vimperator.io.LocalFile.prototype.read =
function fo_read(max)
{
if (this.localFile.isDirectory())
@@ -155,7 +160,7 @@ function fo_read(max)
return rv;
}
LocalFile.prototype.close =
vimperator.io.LocalFile.prototype.close =
function fo_close()
{
if ("outputStream" in this)
@@ -164,7 +169,7 @@ function fo_close()
this.inputStream.close();
}
LocalFile.prototype.flush =
vimperator.io.LocalFile.prototype.flush =
function fo_close()
{
return this.outputStream.flush();

View File

@@ -951,7 +951,7 @@ function Mappings() //{{{
if (url.match(/^file:\/\//) || url.match(/^\//))
{
var stripedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2");
var file = vimperator.fopen(stripedFilename, '<');
var file = vimperator.io.fopen(stripedFilename, '<');
if (!file)
return false;

View File

@@ -269,11 +269,6 @@ const vimperator = (function() //{{{
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
eval: function(string)
{
@@ -582,7 +577,7 @@ const vimperator = (function() //{{{
if (input)
{
filein = getTempFile();
var fdin = vimperator.fopen(filein, ">");
var fdin = vimperator.io.fopen(filein, ">");
fdin.write(input);
fdin.close();
command += " < \"" + filein.path.replace('"', '\\"') + "\"";
@@ -594,7 +589,7 @@ const vimperator = (function() //{{{
else
res = this.run("sh", ["-c", command], true);
var fd = vimperator.fopen(fileout, "<");
var fd = vimperator.io.fopen(fileout, "<");
if (!fd)
return "";
@@ -619,7 +614,7 @@ const vimperator = (function() //{{{
try
{
var fd = vimperator.fopen(filename, "<");
var fd = vimperator.io.fopen(filename, "<");
if (!fd)
return;
@@ -773,7 +768,7 @@ const vimperator = (function() //{{{
if (plugin_dir)
{
var fd = vimperator.fopen(plugin_dir);
var fd = vimperator.io.fopen(plugin_dir);
var entries = fd.read();
fd.close();
vimperator.log("Sourcing plugin directory...", 3);