Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateArguments()

static void System.IO.Strategies.FileStreamHelpers.ValidateArguments ( string path,
FileMode mode,
FileAccess access,
FileShare share,
int bufferSize,
FileOptions options,
long preallocationSize )
inlinestaticpackage

Definition at line 133 of file FileStreamHelpers.cs.

134 {
135 if (path == null)
136 {
137 throw new ArgumentNullException("path", SR.ArgumentNull_Path);
138 }
139 if (path.Length == 0)
140 {
141 throw new ArgumentException(SR.Argument_EmptyPath, "path");
142 }
143 FileShare fileShare = share & ~FileShare.Inheritable;
144 string text = null;
145 if (mode < FileMode.CreateNew || mode > FileMode.Append)
146 {
147 text = "mode";
148 }
149 else if (access < FileAccess.Read || access > FileAccess.ReadWrite)
150 {
151 text = "access";
152 }
153 else if ((fileShare < FileShare.None) || fileShare > (FileShare.ReadWrite | FileShare.Delete))
154 {
155 text = "share";
156 }
157 if (text != null)
158 {
159 throw new ArgumentOutOfRangeException(text, SR.ArgumentOutOfRange_Enum);
160 }
161 if (options != 0 && (options & (FileOptions)67092479) != 0)
162 {
163 throw new ArgumentOutOfRangeException("options", SR.ArgumentOutOfRange_Enum);
164 }
165 if (bufferSize < 0)
166 {
167 ThrowHelper.ThrowArgumentOutOfRangeException_NeedNonNegNum("bufferSize");
168 }
169 else if (preallocationSize < 0)
170 {
171 ThrowHelper.ThrowArgumentOutOfRangeException_NeedNonNegNum("preallocationSize");
172 }
173 if ((access & FileAccess.Write) == 0 && (mode == FileMode.Truncate || mode == FileMode.CreateNew || mode == FileMode.Create || mode == FileMode.Append))
174 {
175 throw new ArgumentException(SR.Format(SR.Argument_InvalidFileModeAndAccessCombo, mode, access), "access");
176 }
177 if ((access & FileAccess.Read) != 0 && mode == FileMode.Append)
178 {
179 throw new ArgumentException(SR.Argument_InvalidAppendMode, "access");
180 }
181 if (preallocationSize > 0)
182 {
184 }
186 }
static void SerializationGuard(FileAccess access)
static void ValidateArgumentsForPreallocation(FileMode mode, FileAccess access)

References System.SR.Argument_EmptyPath, System.SR.Argument_InvalidAppendMode, System.SR.Argument_InvalidFileModeAndAccessCombo, System.SR.ArgumentNull_Path, System.SR.ArgumentOutOfRange_Enum, System.Runtime.Serialization.Dictionary, System.SR.Format(), System.options, System.IO.Strategies.FileStreamHelpers.SerializationGuard(), System.text, System.ThrowHelper.ThrowArgumentOutOfRangeException_NeedNonNegNum(), and System.IO.Strategies.FileStreamHelpers.ValidateArgumentsForPreallocation().

Referenced by System.IO.FileStream.FileStream(), and System.IO.File.OpenHandle().