Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
xpcom.file.URIFile Class Reference
Inheritance diagram for xpcom.file.URIFile:
Inheritance graph
[legend]
Collaboration diagram for xpcom.file.URIFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def init
def read
def readlines
def write
def close
def flush

Public Attributes

 channel
 inputStream
 lockob
 outputStream

Detailed Description

Definition at line 154 of file file.py.


Member Function Documentation

def xpcom.file._File.close (   self) [inherited]

Reimplemented in xpcom.file.LocalFile.

Definition at line 133 of file file.py.

00133 
00134     def close(self):
00135         self._lock()
00136         try:
00137             if self.inputStream is not None:
00138                 self.inputStream.close()
00139                 self.inputStream = None
00140             if self.outputStream is not None:
00141                 self.outputStream.close()
00142                 self.outputStream = None
00143             self.channel = None
00144         finally:
00145             self._release()

Here is the call graph for this function:

Here is the caller graph for this function:

def xpcom.file._File.flush (   self) [inherited]

Definition at line 146 of file file.py.

00146 
00147     def flush(self):
00148         self._lock()
00149         try:
00150             if self.outputStream is not None: self.outputStream.flush()
00151         finally:
00152             self._release()
00153 
# A synchronous "file object" used to open a URI.

Here is the call graph for this function:

def xpcom.file.URIFile.init (   self,
  url,
  mode = "r" 
)

Definition at line 155 of file file.py.

00155 
00156     def init(self, url, mode="r"):
00157         self.close()
00158         if mode != "r":
00159             raise ValueError, "only 'r' mode supported'"
00160         io_service = components.classes["@mozilla.org/network/io-service;1"] \
00161                         .getService(components.interfaces.nsIIOService)
00162         if hasattr(url, "queryInterface"):
00163             url_ob = url
00164         else:
00165             url_ob = io_service.newURI(url, None, None)
00166         # Mozilla asserts and starts saying "NULL POINTER" if this is wrong!
00167         if not url_ob.scheme:
00168             raise ValueError, ("The URI '%s' is invalid (no scheme)" 
00169                                   % (url_ob.spec,))
00170         self.channel = io_service.newChannelFromURI(url_ob)
00171         self.inputStream = self.channel.open()
00172 
00173 # A "file object" implemented using Netscape's native file support.
00174 # Based on io.js - http://lxr.mozilla.org/seamonkey/source/xpcom/tests/utils/io.js
00175 # You open this file using a local file name (as a string) so it really is pointless - 
# you may as well be using a standard Python file object!

Here is the call graph for this function:

def xpcom.file._File.read (   self,
  n = -1 
) [inherited]

Reimplemented in xpcom.file.LocalFile.

Definition at line 109 of file file.py.

00109 
00110     def read(self, n = -1):
00111         assert self.inputStream is not None, "Not setup for read!"
00112         self._lock()
00113         try:
00114             return str(self.inputStream.read(n))
00115         finally:
00116             self._release()

Here is the call graph for this function:

Here is the caller graph for this function:

def xpcom.file._File.readlines (   self) [inherited]

Definition at line 117 of file file.py.

00117 
00118     def readlines(self):
00119         # Not part of the xpcom interface, but handy for direct Python users.
00120         # Not 100% faithful, but near enough for now!
00121         lines = self.read().split("\n")
00122         if len(lines) and len(lines[-1]) == 0:
00123             lines = lines[:-1]
00124         return [s+"\n" for s in lines ]

Here is the call graph for this function:

def xpcom.file._File.write (   self,
  data 
) [inherited]

Definition at line 125 of file file.py.

00125 
00126     def write(self, data):
00127         assert self.outputStream is not None, "Not setup for write!"
00128         self._lock()
00129         try:
00130             self.outputStream.write(data, len(data))
00131         finally:
00132             self._release()

Here is the call graph for this function:


Member Data Documentation

Reimplemented from xpcom.file._File.

Definition at line 169 of file file.py.

Reimplemented from xpcom.file._File.

Definition at line 170 of file file.py.

Definition at line 96 of file file.py.

Reimplemented in xpcom.file.LocalFile.

Definition at line 97 of file file.py.


The documentation for this class was generated from the following file: