Author: ArcRiley
Date: 2007-06-05 23:50:14 -0400 (Tue, 05 Jun 2007)
New Revision: 140

Modified:
   trunk/pysoy/src/_core-all/File.pxi
Log:
about to be redone


Modified: trunk/pysoy/src/_core-all/File.pxi
===================================================================
--- trunk/pysoy/src/_core-all/File.pxi  2007-06-05 17:27:15 UTC (rev 139)
+++ trunk/pysoy/src/_core-all/File.pxi  2007-06-06 03:50:14 UTC (rev 140)
@@ -25,49 +25,28 @@
     This class handles loading and saving .soy and .ogg files efficiently.
   '''
   def __new__(self, path) :
-    self.meta = {}
-    self.objects = {}
-
-    if type(path) == file :  # in case a fd is passed
-      fd = path
-    elif type(path) == str :
-      fd = open(path)
-    else :
-      raise TypeError('Must pass the filename or file object to open')
-    self._file = fd
-    magic = fd.read(4)
-    if magic == 'soy\x00' :
-      self._loadSoy()
-    elif magic == 'OggS'
-      self._type = 1
-      # Todo: scan Ogg file via libogg
-    else :
-      raise IOError('Unknown file format')
+    self._path = path
+    if os.path.isfile(path) :
+      fd = open(path,'r')
+      magic = fd.read(4)
+      if magic == 'ogg\x00' :
         
-  cdef void _loadSoy(self) :
-    cdef object meta
-    cdef object head
+      else :
+        raise IOError('Unknown file format')
+        
+  cdef void _loadSoy(self, file fd, int version) :
+    head = {
+      'size' : unpack('I', self._file.read(4))[0],
+      'name' : self._file.read(20).rstrip('\x00'),
+      'data' : self._file.tell() }
 
-    self._type = 0
-    meta = {}
-    while True :   # Scan .soy file for objects
-      head = {
-        'type' : self._to16bit(self._file.read(2)),
-        'vers' : (self._to8bit(self._file.read(1)), ord(self._file.read(1))),
-        'name' : self._file.read(20).rstrip('\x00'),
-        'size' : unpack('I', self._file.read(4))[0],
-        'data' : self._file.tell()
-      }
-      if head['vers'][0] == 0 and objecttype < len(types) :
+    if head['vers'][0] == 0 and objecttype < len(types) :
         if head['type']] == 0 : # Metadata
           meta = {}
         else :
           
       self._file.seek(head['data'] + head['size'])
 
-  cdef unsigned int _read1  (self) :
-    return self._file.read(1)
-        
   cdef unsigned int _read2 (self) :
     cdef char bytes[3]
     bytes = self._file.read(2)

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to