/[svn]/libgig/trunk/src/RIFF.cpp
ViewVC logotype

Diff of /libgig/trunk/src/RIFF.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2450 by persson, Wed May 8 17:53:07 2013 UTC revision 2482 by schoenebeck, Mon Nov 25 02:22:38 2013 UTC
# Line 1419  namespace RIFF { Line 1419  namespace RIFF {
1419       * @param FileType - four-byte identifier of the RIFF file type       * @param FileType - four-byte identifier of the RIFF file type
1420       * @see AddSubChunk(), AddSubList(), SetByteOrder()       * @see AddSubChunk(), AddSubList(), SetByteOrder()
1421       */       */
1422      File::File(uint32_t FileType) : List(this) {      File::File(uint32_t FileType) : List(this), bIsNewFile(true) {
1423          //HACK: see _GET_RESIZED_CHUNKS() comment          //HACK: see _GET_RESIZED_CHUNKS() comment
1424          ResizedChunks.push_back(reinterpret_cast<Chunk*>(new std::set<Chunk*>));          ResizedChunks.push_back(reinterpret_cast<Chunk*>(new std::set<Chunk*>));
1425          #if defined(WIN32)          #if defined(WIN32)
# Line 1441  namespace RIFF { Line 1441  namespace RIFF {
1441       * @throws RIFF::Exception if error occured while trying to load the       * @throws RIFF::Exception if error occured while trying to load the
1442       *                         given RIFF file       *                         given RIFF file
1443       */       */
1444      File::File(const String& path) : List(this), Filename(path) {      File::File(const String& path) : List(this), Filename(path), bIsNewFile(false) {
1445         #if DEBUG         #if DEBUG
1446         std::cout << "File::File("<<path<<")" << std::endl;         std::cout << "File::File("<<path<<")" << std::endl;
1447         #endif // DEBUG         #endif // DEBUG
# Line 1487  namespace RIFF { Line 1487  namespace RIFF {
1487      String File::GetFileName() {      String File::GetFileName() {
1488          return Filename;          return Filename;
1489      }      }
1490        
1491        void File::SetFileName(const String& path) {
1492            Filename = path;
1493        }
1494    
1495      stream_mode_t File::GetMode() {      stream_mode_t File::GetMode() {
1496          return Mode;          return Mode;
# Line 1718  namespace RIFF { Line 1722  namespace RIFF {
1722          // make sure the RIFF tree is built (from the original file)          // make sure the RIFF tree is built (from the original file)
1723          LoadSubChunksRecursively();          LoadSubChunksRecursively();
1724    
1725          if (Filename.length() > 0) SetMode(stream_mode_read);          if (!bIsNewFile) SetMode(stream_mode_read);
1726          // open the other (new) file for writing and truncate it to zero size          // open the other (new) file for writing and truncate it to zero size
1727          #if POSIX          #if POSIX
1728          hFileWrite = open(path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP);          hFileWrite = open(path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP);
# Line 1766  namespace RIFF { Line 1770  namespace RIFF {
1770    
1771          // associate new file with this File object from now on          // associate new file with this File object from now on
1772          Filename = path;          Filename = path;
1773            bIsNewFile = false;
1774          Mode = (stream_mode_t) -1;       // Just set it to an undefined mode ...          Mode = (stream_mode_t) -1;       // Just set it to an undefined mode ...
1775          SetMode(stream_mode_read_write); // ... so SetMode() has to reopen the file handles.          SetMode(stream_mode_read_write); // ... so SetMode() has to reopen the file handles.
1776      }      }
# Line 1791  namespace RIFF { Line 1796  namespace RIFF {
1796         #endif // DEBUG         #endif // DEBUG
1797          Cleanup();          Cleanup();
1798      }      }
1799        
1800        /**
1801         * Returns @c true if this file has been created new from scratch and
1802         * has not been stored to disk yet.
1803         */
1804        bool File::IsNew() const {
1805            return bIsNewFile;
1806        }
1807    
1808      void File::Cleanup() {      void File::Cleanup() {
1809          #if POSIX          #if POSIX

Legend:
Removed from v.2450  
changed lines
  Added in v.2482

  ViewVC Help
Powered by ViewVC