Skip to content

Commit 030e11d

Browse files
committed
NTFS: NTFSFileSystem: Minor code refactoring
1 parent a378930 commit 030e11d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

DiskAccessLibrary/FileSystems/NTFS/Adapters/NTFSFileSystem.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,24 @@ public override Stream OpenFile(string path, FileMode mode, FileAccess access, F
108108
{
109109
}
110110

111-
if (mode == FileMode.CreateNew)
111+
if (fileExists)
112112
{
113-
if (fileExists)
113+
if (mode == FileMode.CreateNew)
114114
{
115115
throw new AlreadyExistsException();
116116
}
117+
else if (mode == FileMode.Create)
118+
{
119+
mode = FileMode.Truncate;
120+
}
117121
}
118-
119-
if (!fileExists)
122+
else
120123
{
121124
string directoryPath = Path.GetDirectoryName(path);
122125
string fileName = Path.GetFileName(path);
123126
FileRecord directoryRecord = m_volume.GetFileRecord(directoryPath);
124127
fileRecord = m_volume.CreateFile(directoryRecord.BaseSegmentReference, fileName, false);
125128
}
126-
else if (mode == FileMode.Create)
127-
{
128-
mode = FileMode.Truncate;
129-
}
130129
}
131130
else // Open, Truncate or Append
132131
{

0 commit comments

Comments
 (0)