Back to index

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

List of all members.

Public Member Functions

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

Public Attributes

 fileIO
 outputStream
 inputStream
 lockob
 channel

Detailed Description

Definition at line 176 of file file.py.


Constructor & Destructor Documentation

def xpcom.file.LocalFile.__init__ (   self,
  args 
)

Definition at line 177 of file file.py.

00177 
00178     def __init__(self, *args):
00179         self.fileIO = None
00180         _File.__init__(self, *args)


Member Function Documentation

Reimplemented from xpcom.file._File.

Definition at line 206 of file file.py.

00206 
00207     def close(self):
00208         if self.fileIO is not None:
00209             self.fileIO.close()
00210             self.fileIO = None
00211         _File.close(self)

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.LocalFile.init (   self,
  name,
  mode = "r" 
)

Definition at line 181 of file file.py.

00181 
00182     def init(self, name, mode = "r"):
00183         name = os.path.abspath(name) # Moz libraries under Linux fail with relative paths.
00184         self.close()
00185         file = components.classes['@mozilla.org/file/local;1'].createInstance("nsILocalFile")
00186         file.initWithPath(name)
00187         if mode in ["w","a"]:
00188             self.fileIO = components.classes["@mozilla.org/network/file-output-stream;1"].createInstance("nsIFileOutputStream")
00189             if mode== "w":
00190                 if file.exists():
00191                     file.remove(0)
00192                 moz_mode = NS_CREATE_FILE | NS_WRONLY
00193             elif mode=="a":
00194                 moz_mode = NS_APPEND
00195             else:
00196                 assert 0, "Can't happen!"
00197             self.fileIO.init(file, moz_mode, -1,0)
00198             self.outputStream = self.fileIO
00199         elif mode == "r":
00200             self.fileIO = components.classes["@mozilla.org/network/file-input-stream;1"].createInstance("nsIFileInputStream")
00201             self.fileIO.init(file, NS_RDONLY, -1,0)
00202             self.inputStream = components.classes["@mozilla.org/scriptableinputstream;1"].createInstance("nsIScriptableInputStream")
00203             self.inputStream.init(self.fileIO)
00204         else:
00205             raise ValueError, "Unknown mode"

Here is the call graph for this function:

def xpcom.file.LocalFile.read (   self,
  n = -1 
)

Reimplemented from xpcom.file._File.

Definition at line 212 of file file.py.

00212 
00213     def read(self, n = -1):
00214         return _File.read(self, n)
00215 

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 in xpcom.file.URIFile.

Definition at line 142 of file file.py.

Definition at line 178 of file file.py.

Reimplemented from xpcom.file._File.

Definition at line 201 of file file.py.

Definition at line 96 of file file.py.

Reimplemented from xpcom.file._File.

Definition at line 197 of file file.py.


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