You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
collision = true;//empty string test is so that we don't say collision if both are nonexistant - could happen if file is removed/unlinked while reading on some filesystems
115
-
}
116
-
if (collision)
117
-
{
114
+
{//empty string test is so that we don't say collision if both are nonexistant - could happen if file is removed/unlinked while reading on some filesystems
118
115
if (m_writingVersion == writingVersion) return;//don't need to copy to itself
119
-
convertToInMemory();//otherwise, we need to preserve the contents first - if writing fails, we will end up with it converted to in-memory, but oh well
tempRead = tempMemory;//set it to read from the memory rather than m_readingImpl
128
120
}
129
-
if (collision)//drop the in-memory representation afterwards
121
+
shared_ptr<WriteImplInterface> tempWrite(newCiftiOnDiskImpl(myInfo.absoluteFilePath(), m_xml, writingVersion));//NOTE: this makes m_readingImpl/m_writingImpl unusable if collision is true!
if (collision)//if we rewrote the file, we need the handle to the new file, the old one has the wrong version and vox_offset in it
130
124
{
131
125
m_writingVersion = writingVersion;//also record the current version number
132
-
m_writingImpl = tempWrite;
133
-
m_readingImpl = tempWrite;
126
+
if (m_writingImpl != NULL)//NULL can happen if setWritingFile is called with a name other than the current file, then writeFile is called with the same name as current file but different version
127
+
{
128
+
m_writingImpl = tempWrite;//replace the now-unusable old file implementation
129
+
}
130
+
m_readingImpl = tempWrite;//replace the now-unusable old file implementation
shared_ptr<WriteImplInterface> tempWrite(newCiftiMemoryImpl(m_xml));//if we get an error while reading, free the memory immediately, and don't leave m_readingImpl and m_writingImpl pointing to different things
0 commit comments