Exemplo n.º 1
0
        public override void Delete(string path)
        {
            string streamName = GetStreamName(path);

            path = GetFilePath(path);
            FileRecord fileRecord = m_volume.GetFileRecord(path);

            if (streamName == String.Empty)
            {
                m_volume.DeleteFile(fileRecord);
            }
            else
            {
                // We only delete the named stream
                AttributeRecord dataRecord = fileRecord.GetAttributeRecord(AttributeType.Data, streamName);
                if (dataRecord == null)
                {
                    throw new FileNotFoundException(String.Format("The file '{0}' does not contain a stream named '{1}'", path, streamName));
                }
                AttributeData attributeData = new AttributeData(m_volume, fileRecord, dataRecord);
                attributeData.Truncate(0);
                fileRecord.RemoveAttributeRecord(AttributeType.Data, streamName);
                m_volume.UpdateFileRecord(fileRecord);
            }
        }
Exemplo n.º 2
0
        public override void Delete(string path)
        {
            FileRecord fileRecord = m_volume.GetFileRecord(path);

            if (fileRecord != null)
            {
                if (fileRecord.IsDirectory)
                {
                    IndexData directoryIndex = new IndexData(m_volume, fileRecord, AttributeType.FileName);
                    if (!directoryIndex.IsEmpty)
                    {
                        throw new DirectoryNotEmptyException();
                    }
                }
                m_volume.DeleteFile(fileRecord);
            }
            else
            {
                throw new FileNotFoundException();
            }
        }