Commits

stealth977 committed 5fcb7aa

- OGRE::Terrain Fix, Its working again
- OFSHANDLE's Copy Constructor made private, somehow it doesnt work if copied
- Minor OFS Fixes

Comments (0)

Files changed (7)

Dependencies/GenericImageEditor/include/genericimageeditordocument.hxx

     inline void setCodec(IImageEditorCodec* codec){mCodec = codec;}
     inline bool isOfsFile(){return mIsOfsFile;};
     inline OFS::OfsPtr getOfsPtr(){return mOfsPtr;};
-    inline OFS::OFSHANDLE getOfsFileHandle(){return mOfsFileHandle;};
+    inline OFS::OFSHANDLE* getOfsFileHandle(){return &mOfsFileHandle;};
     ToolTipLabel* getLabel(){return mLabel;};
 
 public slots:

Dependencies/GenericTextEditor/include/generictexteditordocument.hxx

     inline void setCodec(ITextEditorCodec* codec){mCodec = codec;}
     inline bool isOfsFile(){return mIsOfsFile;};
     inline OFS::OfsPtr getOfsPtr(){return mOfsPtr;};
-    inline OFS::OFSHANDLE getOfsFileHandle(){return mOfsFileHandle;};
+    inline OFS::OFSHANDLE* getOfsFileHandle(){return &mOfsFileHandle;};
     inline QFile* getFile(){return &mFile;};
     inline void setInitialDisplay(bool initial){mInitialDisplay = initial;};
     inline bool isIntialDisplay(){return mInitialDisplay;};

Dependencies/OFS/include/ofs_base.h

             return ( feof( m_pFile ) != 0 );
         }
 
-        size_t write( const void *data, size_t size )
-        {
-            assert( m_pFile != NULL );
-            return fwrite( data, 1, size, m_pFile );
-        }
+        size_t write( const void *data, size_t size );
 
         size_t read( void *data, size_t size )
         {
         const std::string& getFileSystemName() const { return mFileName; };
 
         /**
+        * Retrieves Base Directory of the file used by Virtual File System
+        * @return Base Directory of the file used by Virtual File System
+        */
+        std::string getFileSystemDirectory();
+
+        /**
+        * Retrieves Type of the Virtual File System
+        * @return Type of the Virtual File System
+        */
+        FileSystemType getFileSystemType() { return mFileSystemType; }
+
+        /**
         * Checks if file system is mounted
         * @return true if file system is mounted
         */
         /* Retrieves file descriptor of a given child in a given directory, null if not found */
         virtual OfsEntryDesc* _findChild(OfsEntryDesc *dir_desc, std::string child_name) = 0;
 
-        FileSystemType getFileSystemType() { return mFileSystemType; }
-
     protected:
         STATIC_AUTO_MUTEX
         AUTO_MUTEX
         * @param value New read position
         */
         void _setReadPos(ofs64 value);
+
+    private:
+
+        /* Assignment operator */
+        OFSHANDLE& operator=(OFSHANDLE& other)
+        {
+            assert(0 && "OFSHANDLE MUST NOT BE COPIED");
+            return *this;
+        }
+
+        /* Construction operator */
+        OFSHANDLE(const OFSHANDLE& other)
+        {
+            assert(0 && "OFSHANDLE MUST NOT BE COPIED");
+        }
     };
 
 

Dependencies/OFS/include/ofs_rfs.h

         /* Internal createDirectory implementation */
         OfsEntryDesc* _createDirectory(OfsEntryDesc *parent, const std::string& name, const UUID& uuid = UUID_ZERO);
         /* Internal createFile implementation */
-        OFSHANDLE _createFile(OfsEntryDesc *parent, const std::string& name, ofs64 file_size, const UUID& uuid = UUID_ZERO, unsigned int data_size = 0, const char *data = NULL);
+        OfsEntryDesc* _createFile(OFSHANDLE &handle, OfsEntryDesc *parent, const std::string& name, ofs64 file_size, const UUID& uuid = UUID_ZERO, unsigned int data_size = 0, const char *data = NULL);
         /* Internal deleteDirectory implementation */
         OfsResult     _deleteDirectory(OfsEntryDesc *dir);
         /* Internal deleteFile implementation */

Dependencies/OFS/source/ofs.cpp

 
 //------------------------------------------------------------------------------
 
+    size_t FileStream::write( const void *data, size_t size )
+    {
+        assert( m_pFile != NULL );
+
+        size_t actual_len =  fwrite( data, 1, size, m_pFile );
+        
+        assert(actual_len == size);
+        
+        return actual_len;
+    }
+
+
     void FileStream::close()
     {
         if( m_pFile != NULL )
     }
 
 
+//------------------------------------------------------------------------------
+
+    std::string _OfsBase::getFileSystemDirectory()
+    {
+        if(mFileSystemType == OFS_RFS )
+            return mFileName;
+        else
+        {
+            int pos1 = mFileName.find_last_of("/");
+            int pos2 = mFileName.find_last_of("\\");
+
+            if( pos2 > pos1 ) pos1 = pos2;
+
+            return mFileName.substr( 0, pos1 );
+        }
+    }
+
+//------------------------------------------------------------------------------
+
     OfsResult _OfsBase::mount(_OfsBase** ptr, const char *file, unsigned int op)
     {
         assert(ptr != 0);
 
         std::string file_name = file;
 
-        if((file_name[file_name.size() - 1] == '/') || (file_name[file_name.size() - 1] == '/'))
-            file_name.erase(file_name.size() - 1, 1);
+        if((file_name[file_name.size() - 1] == '/') || (file_name[file_name.size() - 1] == '/'))
+            file_name.erase(file_name.size() - 1, 1);
 
         NameOfsHandleMap::iterator it = mAllocatedHandles.find(file_name);
 

Dependencies/OFS/source/ofs_rfs.cpp

 
 #include "ofs_rfs.h"
 #include "file_ops.h"
+#include <errno.h>
 #include <algorithm>
 #include <stdio.h>
 
 
 //------------------------------------------------------------------------------
 
-    OFSHANDLE _OfsRfs::_createFile(OfsEntryDesc *parent, const std::string& name, ofs64 file_size, const UUID& uuid, unsigned int data_size, const char *data)
+    _OfsRfs::OfsEntryDesc* _OfsRfs::_createFile(OFSHANDLE &handle, OfsEntryDesc *parent, const std::string& name, ofs64 file_size, const UUID& uuid, unsigned int data_size, const char *data)
     {
         assert(parent != NULL);
         
-        OFSHANDLE result;
-        result.mEntryDesc = NULL;
-        
         OfsEntryDesc *file = new OfsEntryDesc();
 
         file->Owner = this;
         file->Flags = OFS_FILE;
         file->OldParentId = ROOT_DIRECTORY_ID;
         file->Name = name;
-        file->FileSize = file_size;
+        file->FileSize = data_size;
         file->Parent = parent;
         file->CreationTime = time( NULL );
         file->UseCount = 0;
         file->WriteLocked = false;
         file->Uuid = uuid;
 
+        std::string full_path = mFileName + constructFullPath( file );
+
+        handle.mStream.open(full_path.c_str(), "wb+");
+        if( handle.mStream.fail() )
+        {
+            delete file;
+            return NULL;
+        }
+
+        if( data_size > 0 )
+            handle.mStream.write(data, data_size);
+
+        handle.mEntryDesc = file;
         parent->Children.push_back(file);
 
-        if(uuid != UUID_ZERO)
-        {
-            UuidDescMap::const_iterator it = mUuidMap.find(uuid);
-
-            if(it != mUuidMap.end())
-            {
-                delete file;
-
-                OFS_EXCEPT("_OfsRfs::_createFile, The UUID supplied already exists.");
-
-                return result;
-            }
-            else
-            {
-                mUuidMap.insert(UuidDescMap::value_type(uuid, file));
-            }
-        }
-
-        std::string full_path = mFileName + constructFullPath( file );
-
-        result.mEntryDesc = file;
-        result.mStream.open(full_path.c_str(), "wb+");
-        result.mStream.write(data, data_size);
-
-        return result;
+        return file;
     }
 
 //------------------------------------------------------------------------------
                 }
             }
 
-            handle = _createFile(dirDesc, fName, file_size, uuid, data_size, data);
-            fileDesc = handle.mEntryDesc;
-
+            fileDesc = _createFile(handle, dirDesc, fName, file_size, uuid, data_size, data);
 
             if(fileDesc != NULL)
             {
         if(actual_read != NULL)
             *actual_read = length;
 
+        handle.mReadPos = handle.mStream.tell();
+
         return OFS_OK;
     }
 
 
         length = handle.mStream.write(src, length);
 
-        ofs64 pos = handle.mStream.tell();
-
-        if( pos < handle.mEntryDesc->FileSize )
-            handle.mEntryDesc->FileSize = pos;
+        handle.mReadPos = handle.mStream.tell();
+
+        if( handle.mReadPos > handle.mEntryDesc->FileSize )
+            handle.mEntryDesc->FileSize = handle.mReadPos;
 
         return OFS_OK;
     }
                           break;
         }
 
-        return handle.mStream.tell();
+        handle.mReadPos = handle.mStream.tell();
+
+        return handle.mReadPos;
     }
 
 //------------------------------------------------------------------------------
                           break;
         }
 
-        return handle.mStream.tell();
+        handle.mReadPos = handle.mStream.tell();
+
+        return handle.mReadPos;
     }
 
 //------------------------------------------------------------------------------
             return 0;
         }
 
-        return handle.mStream.tell();
+        return handle.mReadPos;
     }
 
 //------------------------------------------------------------------------------
             return 0;
         }
 
-        return handle.mStream.tell();
+        return handle.mReadPos;
     }
 
 //------------------------------------------------------------------------------

Ogitor/src/TerrainPageEditor.cpp

         filename = mTempFileName;
     }
 
-    Ogre::String tmpCompressFile = OgitorsUtils::ExtractFilePath(mOgitorsRoot->GetProjectFile()->getFileSystemName()) + "Temp/";
+    Ogre::String tmpCompressFile = mOgitorsRoot->GetProjectFile()->getFileSystemDirectory() + "/Temp/";
     tmpCompressFile = tmpCompressFile + Ogre::StringConverter::toString(mObjectID->get()) + ".compress";
 
     OFS::OFSHANDLE *fileHandle = new OFS::OFSHANDLE();
     mHandle->load(0, true);
 
     Ogre::DataStreamPtr stream = Ogre::DataStreamPtr(OGRE_NEW OfsDataStream(mOgitorsRoot->GetProjectFile(), fileHandle));
-    Ogre::DataStreamPtr compressStream(OGRE_NEW Ogre::DeflateStream(filename, stream, tmpCompressFile));
-    Ogre::StreamSerialiser ser(compressStream);
+    //Ogre::DataStreamPtr compressStream(OGRE_NEW Ogre::DeflateStream(filename, stream, tmpCompressFile));
+    //Ogre::StreamSerialiser ser(compressStream);
+    Ogre::StreamSerialiser ser(stream);
     mHandle->save(ser);
 }
 //-----------------------------------------------------------------------------------------
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 ProjectModifiedEvent.java.
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.