/// <summary>
 /// Replaces the existing settings with this new set.
 /// </summary>
 /// <param name="settings"></param>
 public void UpdateSettings(ArchiveInitializerSettings settings)
 {
     settings = settings.CloneReadonly();
     settings.Validate();
     using (m_lock.EnterWriteLock())
     {
         m_settings = settings;
     }
 }
示例#2
0
        /// <summary>
        /// Changes the extension of the current file.
        /// </summary>
        /// <param name="extension">the new extension</param>
        /// <param name="isReadOnly">If the file should be reopened as readonly</param>
        /// <param name="isSharingEnabled">If the file should share read privileges.</param>
        public void ChangeExtension(string extension, bool isReadOnly, bool isSharingEnabled)
        {
            using (m_isUsingStream.EnterWriteLock())
            {
                string oldFileName = m_stream.Name;
                string newFileName = Path.ChangeExtension(oldFileName, extension);
                if (File.Exists(newFileName))
                {
                    throw new Exception("New file already exists with this extension");
                }

                m_stream.Dispose();
                m_stream = null;
                File.Move(oldFileName, newFileName);
                m_stream           = new FileStream(newFileName, FileMode.Open, isReadOnly ? FileAccess.Read : FileAccess.ReadWrite, isSharingEnabled ? FileShare.Read : FileShare.None, 2048, true);
                m_fileName         = newFileName;
                m_isSharingEnabled = isSharingEnabled;
                m_isReadOnly       = isReadOnly;
            }
        }
示例#3
0
        /// <summary>
        /// Opens the underlying file stream
        /// </summary>
        public void Open()
        {
            using (m_isUsingStream.EnterWriteLock())
            {
                if (m_streamUsers == 0)
                {
                    m_stream = new FileStream(m_fileName, FileMode.Open, m_isReadOnly ? FileAccess.Read : FileAccess.ReadWrite, m_isSharingEnabled ? FileShare.Read : FileShare.None, 2048, true);
                }

                m_streamUsers++;
            }
        }