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) |
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 |
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; |
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); |
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 |
} |
} |
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 |