--- libgig/trunk/src/RIFF.cpp 2013/11/07 18:22:48 2481 +++ libgig/trunk/src/RIFF.cpp 2013/11/25 02:22:38 2482 @@ -1419,7 +1419,7 @@ * @param FileType - four-byte identifier of the RIFF file type * @see AddSubChunk(), AddSubList(), SetByteOrder() */ - File::File(uint32_t FileType) : List(this) { + File::File(uint32_t FileType) : List(this), bIsNewFile(true) { //HACK: see _GET_RESIZED_CHUNKS() comment ResizedChunks.push_back(reinterpret_cast(new std::set)); #if defined(WIN32) @@ -1441,7 +1441,7 @@ * @throws RIFF::Exception if error occured while trying to load the * given RIFF file */ - File::File(const String& path) : List(this), Filename(path) { + File::File(const String& path) : List(this), Filename(path), bIsNewFile(false) { #if DEBUG std::cout << "File::File("< 0) SetMode(stream_mode_read); + if (!bIsNewFile) SetMode(stream_mode_read); // open the other (new) file for writing and truncate it to zero size #if POSIX hFileWrite = open(path.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP); @@ -1766,6 +1770,7 @@ // associate new file with this File object from now on Filename = path; + bIsNewFile = false; Mode = (stream_mode_t) -1; // Just set it to an undefined mode ... SetMode(stream_mode_read_write); // ... so SetMode() has to reopen the file handles. } @@ -1791,6 +1796,14 @@ #endif // DEBUG Cleanup(); } + + /** + * Returns @c true if this file has been created new from scratch and + * has not been stored to disk yet. + */ + bool File::IsNew() const { + return bIsNewFile; + } void File::Cleanup() { #if POSIX