Skip to content

Commit

Permalink
NTFS: NTFSFileSystem: Minor code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TalAloni committed Nov 8, 2018
1 parent a378930 commit 030e11d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions DiskAccessLibrary/FileSystems/NTFS/Adapters/NTFSFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,24 @@ public override Stream OpenFile(string path, FileMode mode, FileAccess access, F
{
}

if (mode == FileMode.CreateNew)
if (fileExists)
{
if (fileExists)
if (mode == FileMode.CreateNew)
{
throw new AlreadyExistsException();
}
else if (mode == FileMode.Create)
{
mode = FileMode.Truncate;
}
}

if (!fileExists)
else
{
string directoryPath = Path.GetDirectoryName(path);
string fileName = Path.GetFileName(path);
FileRecord directoryRecord = m_volume.GetFileRecord(directoryPath);
fileRecord = m_volume.CreateFile(directoryRecord.BaseSegmentReference, fileName, false);
}
else if (mode == FileMode.Create)
{
mode = FileMode.Truncate;
}
}
else // Open, Truncate or Append
{
Expand Down

0 comments on commit 030e11d

Please sign in to comment.