Philippe Lagadec committed 1ba7fff

Added comments for patch submitted by mete0r_kr, changed version

Comments (0)

Files changed (1)


     Microsoft Compound Document File Format), such as Microsoft Office
     documents, Image Composer and FlashPix files, Outlook messages, ...
-version 0.22 2012-02-16 Philippe Lagadec -
+version 0.23 2012-07-25 Philippe Lagadec -
 Project website:
 __author__  = "Fredrik Lundh (Secret Labs AB), Philippe Lagadec"
-__date__    = "2012-02-16"
-__version__ = '0.22'
+__date__    = "2012-07-25"
+__version__ = '0.23'
 #--- LICENSE ------------------------------------------------------------------
 # 2012-02-16 v0.22 PL: - fixed bug in getproperties, patch by chuckleberryfinn
 #                        (
 #                      - added close method to OleFileIO (fixed issue #2)
+# 2012-07-25 v0.23 PL: - added support for file-like objects (patch by mete0r_kr)
 # TODO (for version 1.0):
         offset    : offset in bytes for the first FAT or MiniFAT sector
         sectorsize: size of one sector
         fat       : array/list of sector indexes (FAT or MiniFAT)
+        filesize  : size of OLE file (for debugging)
         return    : a StringIO instance containing the OLE stream
             # file-like object
             self.fp = filename
-            # string-like object
+            # string-like object: filename of file on disk
+            #TODO: if larger than 1024 bytes, this could be the actual data => StringIO
             self.fp = open(filename, "rb")
         # old code fails if filename is not a plain string:
         #if type(filename) == type(""):
         #    self.fp = open(filename, "rb")
         #    self.fp = filename
-, 2)
+        # obtain the filesize by using seek and tell, which should work on most
+        # file-like objects:
+        #TODO: do it above, using getsize with filename when possible?
+        #TODO: fix code to fail with clear exception when filesize cannot be obtained
+, os.SEEK_END)
             filesize = self.fp.tell()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.