From 8f5cef936491e8b20888bbf18d426482c890637c Mon Sep 17 00:00:00 2001 From: Alexis Christoforides Date: Fri, 1 Feb 2019 03:48:09 -0500 Subject: [PATCH] [corlib] Import System.IO.File from CoreFX (#12000) Contributes to #7246 --- bcl.sln | 6 +- external/api-snapshot | 2 +- external/corefx | 2 +- mcs/class/Mono.CSharp/Mono.CSharp.csproj | 8 + mcs/class/corlib/System.IO/File.cs | 737 ------------------ mcs/class/corlib/Test/System.IO/FileTest.cs | 194 +---- mcs/class/corlib/corefx/File.cs | 31 + mcs/class/corlib/corefx/SR.cs | 1 + mcs/class/corlib/corlib.csproj | 29 +- mcs/class/corlib/corlib.dll.sources | 7 +- mcs/class/corlib/corlib_xtest.dll.sources | 7 +- .../corlib/unix_build_corlib.dll.sources | 2 + .../wasm_corlib_xtest.dll.exclude.sources | 15 +- .../corlib/win32_build_corlib.dll.sources | 1 + sdks/wasm/driver.c | 2 + 15 files changed, 92 insertions(+), 952 deletions(-) delete mode 100644 mcs/class/corlib/System.IO/File.cs create mode 100644 mcs/class/corlib/corefx/File.cs diff --git a/bcl.sln b/bcl.sln index 2ac8f3f986a65..04d577d055f30 100644 --- a/bcl.sln +++ b/bcl.sln @@ -3366,8 +3366,10 @@ Global {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Release|wasm.ActiveCfg = Release|net_4_x {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Debug|winaot.ActiveCfg = Debug|net_4_x {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Release|winaot.ActiveCfg = Release|net_4_x - {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Debug|xammac.ActiveCfg = Debug|net_4_x - {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Release|xammac.ActiveCfg = Release|net_4_x + {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Debug|xammac.ActiveCfg = Debug|xammac + {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Debug|xammac.Build.0 = Debug|xammac + {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Release|xammac.ActiveCfg = Release|xammac + {817CE046-07E8-409D-84BF-A6EA4F2879DE}.Release|xammac.Build.0 = Release|xammac {767CAD15-F8B5-4EAC-8B3D-4EF75F768015}.Debug|net_4_x.ActiveCfg = Debug|net_4_x {767CAD15-F8B5-4EAC-8B3D-4EF75F768015}.Debug|net_4_x.Build.0 = Debug|net_4_x {767CAD15-F8B5-4EAC-8B3D-4EF75F768015}.Release|net_4_x.ActiveCfg = Release|net_4_x diff --git a/external/api-snapshot b/external/api-snapshot index dd4052cc15a46..67d69fbf8c409 160000 --- a/external/api-snapshot +++ b/external/api-snapshot @@ -1 +1 @@ -Subproject commit dd4052cc15a46d48524a47c1e39862fe825a0e96 +Subproject commit 67d69fbf8c409cd56bbf91013bd853188f279631 diff --git a/external/corefx b/external/corefx index 5d1517a4db399..862b6c67d0608 160000 --- a/external/corefx +++ b/external/corefx @@ -1 +1 @@ -Subproject commit 5d1517a4db399ca8caabefa7ce36f97cefe0aae1 +Subproject commit 862b6c67d060870e619dd88189662d5fbf2b01b1 diff --git a/mcs/class/Mono.CSharp/Mono.CSharp.csproj b/mcs/class/Mono.CSharp/Mono.CSharp.csproj index 08b8d65418461..d65e520d9f4b5 100644 --- a/mcs/class/Mono.CSharp/Mono.CSharp.csproj +++ b/mcs/class/Mono.CSharp/Mono.CSharp.csproj @@ -80,6 +80,11 @@ ./../../class/obj/$(AssemblyName)-testing_aot_full NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_LEGACY;FULL_AOT_DESKTOP;FULL_AOT_RUNTIME;DISABLE_REMOTING;DISABLE_COM;IOS_REFLECTION;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_PROCESS_START + + ./../../class/lib/xammac + ./../../class/obj/$(AssemblyName)-xammac + NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;MOBILE;MOBILE_DYNAMIC;XAMMAC;FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK;XAMARIN_MODERN;MONO_FEATURE_THREAD_ABORT;MONO_FEATURE_PROCESS_START + ./../../class/lib/xammac_net_4_5 ./../../class/obj/$(AssemblyName)-xammac_net_4_5 @@ -131,6 +136,9 @@ + + + diff --git a/mcs/class/corlib/System.IO/File.cs b/mcs/class/corlib/System.IO/File.cs deleted file mode 100644 index d6fef5a1304bb..0000000000000 --- a/mcs/class/corlib/System.IO/File.cs +++ /dev/null @@ -1,737 +0,0 @@ -// -// System.IO.File.cs -// -// -// Authors: -// Miguel de Icaza (miguel@ximian.com) -// Jim Richardson (develop@wtfo-guru.com) -// Dan Lewis (dihlewis@yahoo.co.uk) -// Ville Palo (vi64pa@kolumbus.fi) -// -// Copyright 2002 Ximian, Inc. http://www.ximian.com -// Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved -// Copyright (C) 2004, 2006, 2010 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Security; -using System.Text; -using System.Runtime.InteropServices; -using System.Security.AccessControl; - -namespace System.IO -{ - [ComVisible (true)] - public static class File - { - public static void AppendAllText (string path, string contents) - { - using (TextWriter w = new StreamWriter (path, true)) { - w.Write (contents); - } - } - - public static void AppendAllText (string path, string contents, Encoding encoding) - { - using (TextWriter w = new StreamWriter (path, true, encoding)) { - w.Write (contents); - } - } - - public static StreamWriter AppendText (string path) - { - return new StreamWriter (path, true); - } - - public static void Copy (string sourceFileName, string destFileName) - { - Copy (sourceFileName, destFileName, false); - } - - public static void Copy (string sourceFileName, string destFileName, bool overwrite) - { - MonoIOError error; - - if (sourceFileName == null) - throw new ArgumentNullException ("sourceFileName"); - if (destFileName == null) - throw new ArgumentNullException ("destFileName"); - if (sourceFileName.Length == 0) - throw new ArgumentException ("An empty file name is not valid.", "sourceFileName"); - if (sourceFileName.Trim ().Length == 0 || sourceFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("The file name is not valid."); - if (destFileName.Length == 0) - throw new ArgumentException ("An empty file name is not valid.", "destFileName"); - if (destFileName.Trim ().Length == 0 || destFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("The file name is not valid."); - - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - if (!MonoIO.Exists (sourceFileName, out error)) - throw new FileNotFoundException (Locale.GetText ("{0} does not exist", sourceFileName), sourceFileName); - if ((GetAttributes (sourceFileName) & FileAttributes.Directory) == FileAttributes.Directory) - throw new ArgumentException (Locale.GetText ("{0} is a directory", sourceFileName)); - - if (MonoIO.Exists (destFileName, out error)) { - if ((GetAttributes (destFileName) & FileAttributes.Directory) == FileAttributes.Directory) - throw new ArgumentException (Locale.GetText ("{0} is a directory", destFileName)); - if (!overwrite) - throw new IOException (Locale.GetText ("{0} already exists", destFileName)); - } - - string DirName = Path.GetDirectoryName (destFileName); - if (DirName != String.Empty && !Directory.Exists (DirName)) - throw new DirectoryNotFoundException (Locale.GetText ("Destination directory not found: {0}",DirName)); - - if (!MonoIO.CopyFile (sourceFileName, destFileName, overwrite, out error)) { - string p = Locale.GetText ("{0}\" or \"{1}", sourceFileName, destFileName); - throw MonoIO.GetException (p, error); - } - } - - internal static String InternalCopy (String sourceFileName, String destFileName, bool overwrite, bool checkHost) - { - String fullSourceFileName = Path.GetFullPathInternal(sourceFileName); - String fullDestFileName = Path.GetFullPathInternal(destFileName); - - MonoIOError error; - - if (!MonoIO.CopyFile (fullSourceFileName, fullDestFileName, overwrite, out error)) { - string p = Locale.GetText ("{0}\" or \"{1}", sourceFileName, destFileName); - throw MonoIO.GetException (p, error); - } - - return fullDestFileName; - } - - public static FileStream Create (string path) - { - return Create (path, 8192); - } - - public static FileStream Create (string path, int bufferSize) - { - return new FileStream (path, FileMode.Create, FileAccess.ReadWrite, - FileShare.None, bufferSize); - } - - [MonoLimitation ("FileOptions are ignored")] - public static FileStream Create (string path, int bufferSize, - FileOptions options) - { - return new FileStream (path, FileMode.Create, FileAccess.ReadWrite, - FileShare.None, bufferSize, options); - } - - [MonoLimitation ("FileOptions and FileSecurity are ignored")] - public static FileStream Create (string path, int bufferSize, - FileOptions options, - FileSecurity fileSecurity) - { - return new FileStream (path, FileMode.Create, FileAccess.ReadWrite, - FileShare.None, bufferSize, options); - } - - public static StreamWriter CreateText (string path) - { - return new StreamWriter (path, false); - } - - public static void Delete (string path) - { - Path.Validate (path); - if (Directory.Exists (path)) - throw new UnauthorizedAccessException(Locale.GetText ("{0} is a directory", path)); - - string DirName = Path.GetDirectoryName(path); - if (DirName != String.Empty && !Directory.Exists (DirName)) - throw new DirectoryNotFoundException (Locale.GetText ("Could not find a part of the path \"{0}\".", path)); - - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - MonoIOError error; - - if (!MonoIO.DeleteFile (path, out error)){ - if (error != MonoIOError.ERROR_FILE_NOT_FOUND) - throw MonoIO.GetException (path, error); - } - } - - public static bool Exists (string path) - { - // For security reasons no exceptions are - // thrown, only false is returned if there is - // any problem with the path or permissions. - // Minimizes what information can be - // discovered by using this method. - if (String.IsNullOrWhiteSpace (path) || path.IndexOfAny(Path.InvalidPathChars) >= 0) - return false; - - // on Moonlight this does not throw but returns false - if (!SecurityManager.CheckElevatedPermissions ()) - return false; - - MonoIOError error; - return MonoIO.ExistsFile (path, out error); - } - - public static FileSecurity GetAccessControl (string path) - { - // AccessControlSections.Audit requires special permissions. - return GetAccessControl (path, - AccessControlSections.Owner | - AccessControlSections.Group | - AccessControlSections.Access); - } - - public static FileSecurity GetAccessControl (string path, AccessControlSections includeSections) - { - return new FileSecurity (path, includeSections); - } - - public static FileAttributes GetAttributes (string path) - { - Path.Validate (path); - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - MonoIOError error; - FileAttributes attrs; - - attrs = MonoIO.GetFileAttributes (path, out error); - if (error != MonoIOError.ERROR_SUCCESS) - throw MonoIO.GetException (path, error); - return attrs; - } - - public static DateTime GetCreationTime (string path) - { - MonoIOStat stat; - MonoIOError error; - Path.Validate (path); - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - if (!MonoIO.GetFileStat (path, out stat, out error)) { - if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND) - return DefaultLocalFileTime; - else - throw new IOException (path); - } - return DateTime.FromFileTime (stat.CreationTime); - } - - public static DateTime GetCreationTimeUtc (string path) - { - return GetCreationTime (path).ToUniversalTime (); - } - - public static DateTime GetLastAccessTime (string path) - { - MonoIOStat stat; - MonoIOError error; - Path.Validate (path); - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - if (!MonoIO.GetFileStat (path, out stat, out error)) { - if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND) - return DefaultLocalFileTime; - else - throw new IOException (path); - } - return DateTime.FromFileTime (stat.LastAccessTime); - } - - public static DateTime GetLastAccessTimeUtc (string path) - { - return GetLastAccessTime (path).ToUniversalTime (); - } - - public static DateTime GetLastWriteTime (string path) - { - MonoIOStat stat; - MonoIOError error; - Path.Validate (path); - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - if (!MonoIO.GetFileStat (path, out stat, out error)) { - if (error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_FILE_NOT_FOUND) - return DefaultLocalFileTime; - else - throw new IOException (path); - } - return DateTime.FromFileTime (stat.LastWriteTime); - } - - public static DateTime GetLastWriteTimeUtc (string path) - { - return GetLastWriteTime (path).ToUniversalTime (); - } - - public static void Move (string sourceFileName, string destFileName) - { - if (sourceFileName == null) - throw new ArgumentNullException ("sourceFileName"); - if (destFileName == null) - throw new ArgumentNullException ("destFileName"); - if (sourceFileName.Length == 0) - throw new ArgumentException ("An empty file name is not valid.", "sourceFileName"); - if (sourceFileName.Trim ().Length == 0 || sourceFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("The file name is not valid."); - if (destFileName.Length == 0) - throw new ArgumentException ("An empty file name is not valid.", "destFileName"); - if (destFileName.Trim ().Length == 0 || destFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("The file name is not valid."); - - SecurityManager.EnsureElevatedPermissions (); // this is a no-op outside moonlight - - MonoIOError error; - if (!MonoIO.Exists (sourceFileName, out error)) - throw new FileNotFoundException (Locale.GetText ("{0} does not exist", sourceFileName), sourceFileName); - - // Don't check for this error here to allow the runtime - // to check if sourceFileName and destFileName are equal. - // Comparing sourceFileName and destFileName is not enough. - //if (MonoIO.Exists (destFileName, out error)) - // throw new IOException (Locale.GetText ("{0} already exists", destFileName)); - - string DirName; - DirName = Path.GetDirectoryName (destFileName); - if (DirName != String.Empty && !Directory.Exists (DirName)) - throw new DirectoryNotFoundException (Locale.GetText ("Could not find a part of the path.")); - - if (!MonoIO.MoveFile (sourceFileName, destFileName, out error)) { - if (error == MonoIOError.ERROR_ALREADY_EXISTS) - throw MonoIO.GetException (error); - else if (error == MonoIOError.ERROR_SHARING_VIOLATION) - throw MonoIO.GetException (sourceFileName, error); - - throw MonoIO.GetException (error); - } - } - - public static FileStream Open (string path, FileMode mode) - { - return new FileStream (path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None); - } - - public static FileStream Open (string path, FileMode mode, FileAccess access) - { - return new FileStream (path, mode, access, FileShare.None); - } - - public static FileStream Open (string path, FileMode mode, FileAccess access, - FileShare share) - { - return new FileStream (path, mode, access, share); - } - - public static FileStream OpenRead (string path) - { - return new FileStream (path, FileMode.Open, FileAccess.Read, FileShare.Read); - } - - public static StreamReader OpenText (string path) - { - return new StreamReader (path); - } - - public static FileStream OpenWrite (string path) - { - return new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); - } - - public static void Replace (string sourceFileName, - string destinationFileName, - string destinationBackupFileName) - { - Replace (sourceFileName, destinationFileName, destinationBackupFileName, false); - } - - public static void Replace (string sourceFileName, - string destinationFileName, - string destinationBackupFileName, - bool ignoreMetadataErrors) - { - MonoIOError error; - - if (sourceFileName == null) - throw new ArgumentNullException ("sourceFileName"); - if (destinationFileName == null) - throw new ArgumentNullException ("destinationFileName"); - if (sourceFileName.Trim ().Length == 0 || sourceFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("sourceFileName"); - if (destinationFileName.Trim ().Length == 0 || destinationFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("destinationFileName"); - - string fullSource = Path.GetFullPath (sourceFileName); - string fullDest = Path.GetFullPath (destinationFileName); - if (MonoIO.ExistsDirectory (fullSource, out error)) - throw new IOException (Locale.GetText ("{0} is a directory", sourceFileName)); - if (MonoIO.ExistsDirectory (fullDest, out error)) - throw new IOException (Locale.GetText ("{0} is a directory", destinationFileName)); - - if (!Exists (fullSource)) - throw new FileNotFoundException (Locale.GetText ("{0} does not exist", sourceFileName), - sourceFileName); - if (!Exists (fullDest)) - throw new FileNotFoundException (Locale.GetText ("{0} does not exist", destinationFileName), - destinationFileName); - if (fullSource == fullDest) - throw new IOException (Locale.GetText ("Source and destination arguments are the same file.")); - - string fullBackup = null; - if (destinationBackupFileName != null) { - if (destinationBackupFileName.Trim ().Length == 0 || - destinationBackupFileName.IndexOfAny (Path.InvalidPathChars) != -1) - throw new ArgumentException ("destinationBackupFileName"); - - fullBackup = Path.GetFullPath (destinationBackupFileName); - if (MonoIO.ExistsDirectory (fullBackup, out error)) - throw new IOException (Locale.GetText ("{0} is a directory", destinationBackupFileName)); - if (fullSource == fullBackup) - throw new IOException (Locale.GetText ("Source and backup arguments are the same file.")); - if (fullDest == fullBackup) - throw new IOException (Locale.GetText ( - "Destination and backup arguments are the same file.")); - } - - var attrs = GetAttributes (fullDest); - - // TODO: Should be done in wapi, win32 api handles this already - if ((attrs & FileAttributes.ReadOnly) != 0) - throw MonoIO.GetException (MonoIOError.ERROR_ACCESS_DENIED); - - if (!MonoIO.ReplaceFile (fullSource, fullDest, fullBackup, - ignoreMetadataErrors, out error)) { - throw MonoIO.GetException (error); - } - } - - public static void SetAccessControl (string path, - FileSecurity fileSecurity) - { - if (null == fileSecurity) - throw new ArgumentNullException ("fileSecurity"); - - fileSecurity.PersistModifications (path); - } - - public static void SetAttributes (string path, - FileAttributes fileAttributes) - { - MonoIOError error; - Path.Validate (path); - - if (!MonoIO.SetFileAttributes (path, fileAttributes, out error)) - throw MonoIO.GetException (path, error); - } - - public static void SetCreationTime (string path, DateTime creationTime) - { - MonoIOError error; - Path.Validate (path); - if (!MonoIO.Exists (path, out error)) - throw MonoIO.GetException (path, error); - if (!MonoIO.SetCreationTime (path, creationTime, out error)) - throw MonoIO.GetException (path, error); - } - - public static void SetCreationTimeUtc (string path, DateTime creationTimeUtc) - { - SetCreationTime (path, creationTimeUtc.ToLocalTime ()); - } - - public static void SetLastAccessTime (string path, DateTime lastAccessTime) - { - MonoIOError error; - Path.Validate (path); - if (!MonoIO.Exists (path, out error)) - throw MonoIO.GetException (path, error); - if (!MonoIO.SetLastAccessTime (path, lastAccessTime, out error)) - throw MonoIO.GetException (path, error); - } - - public static void SetLastAccessTimeUtc (string path, DateTime lastAccessTimeUtc) - { - SetLastAccessTime (path, lastAccessTimeUtc.ToLocalTime ()); - } - - public static void SetLastWriteTime (string path, - DateTime lastWriteTime) - { - MonoIOError error; - Path.Validate (path); - if (!MonoIO.Exists (path, out error)) - throw MonoIO.GetException (path, error); - if (!MonoIO.SetLastWriteTime (path, lastWriteTime, out error)) - throw MonoIO.GetException (path, error); - } - - public static void SetLastWriteTimeUtc (string path, - DateTime lastWriteTimeUtc) - { - SetLastWriteTime (path, lastWriteTimeUtc.ToLocalTime ()); - } - - // - // The documentation for this method is most likely wrong, it - // talks about doing a "binary read", but the remarks say - // that this "detects the encoding". - // - // This can not detect and do anything useful with the encoding - // since the result is a byte [] not a char []. - // - public static byte [] ReadAllBytes (string path) - { - using (FileStream s = OpenRead (path)) { - long size = s.Length; - // limited to 2GB according to http://msdn.microsoft.com/en-us/library/system.io.file.readallbytes.aspx - if (size > Int32.MaxValue) - throw new IOException ("Reading more than 2GB with this call is not supported"); - - int pos = 0; - int count = (int) size; - byte [] result = new byte [size]; - while (count > 0) { - int n = s.Read (result, pos, count); - if (n == 0) - throw new IOException ("Unexpected end of stream"); - pos += n; - count -= n; - } - return result; - } - } - - public static string [] ReadAllLines (string path) - { - using (StreamReader reader = File.OpenText (path)) { - return ReadAllLines (reader); - } - } - - public static string [] ReadAllLines (string path, Encoding encoding) - { - using (StreamReader reader = new StreamReader (path, encoding)) { - return ReadAllLines (reader); - } - } - - static string [] ReadAllLines (StreamReader reader) - { - List list = new List (); - while (!reader.EndOfStream) - list.Add (reader.ReadLine ()); - return list.ToArray (); - } - - public static string ReadAllText (string path) - { - using (StreamReader sr = new StreamReader (path)) { - return sr.ReadToEnd (); - } - } - - public static string ReadAllText (string path, Encoding encoding) - { - using (StreamReader sr = new StreamReader (path, encoding)) { - return sr.ReadToEnd (); - } - } - - public static void WriteAllBytes (string path, byte [] bytes) - { - using (Stream stream = File.Create (path)) { - stream.Write (bytes, 0, bytes.Length); - } - } - - public static void WriteAllLines (string path, string [] contents) - { - using (StreamWriter writer = new StreamWriter (path)) { - WriteAllLines (writer, contents); - } - } - - public static void WriteAllLines (string path, string [] contents, Encoding encoding) - { - using (StreamWriter writer = new StreamWriter (path, false, encoding)) { - WriteAllLines (writer, contents); - } - } - - static void WriteAllLines (StreamWriter writer, string [] contents) - { - foreach (string line in contents) - writer.WriteLine (line); - } - - public static void WriteAllText (string path, string contents) - { - WriteAllText (path, contents, EncodingHelper.UTF8Unmarked); - } - - public static void WriteAllText (string path, string contents, Encoding encoding) - { - using (StreamWriter sw = new StreamWriter (path, false, encoding)) { - sw.Write (contents); - } - } - - static DateTime? defaultLocalFileTime; - static DateTime DefaultLocalFileTime { - get { - if (defaultLocalFileTime == null) - defaultLocalFileTime = new DateTime (1601, 1, 1).ToLocalTime (); - - return defaultLocalFileTime.Value; - } - } - - - [MonoLimitation ("File encryption isn't supported (even on NTFS).")] - public static void Encrypt (string path) - { - // MS.NET support this only on NTFS file systems, i.e. it's a file-system (not a framework) feature. - // otherwise it throws a NotSupportedException (or a PlatformNotSupportedException on older OS). - // we throw the same (instead of a NotImplementedException) because most code should already be - // handling this exception to work properly. - throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system.")); - } - - [MonoLimitation ("File encryption isn't supported (even on NTFS).")] - public static void Decrypt (string path) - { - // MS.NET support this only on NTFS file systems, i.e. it's a file-system (not a framework) feature. - // otherwise it throws a NotSupportedException (or a PlatformNotSupportedException on older OS). - // we throw the same (instead of a NotImplementedException) because most code should already be - // handling this exception to work properly. - throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system.")); - } - - public static IEnumerable ReadLines (string path) - { - return ReadLines (File.OpenText (path)); - } - - public static IEnumerable ReadLines (string path, Encoding encoding) - { - return ReadLines (new StreamReader (path, encoding)); - } - - // refactored in order to avoid compiler-generated names for Moonlight tools - static IEnumerable ReadLines (StreamReader reader) - { - using (reader) { - string s; - while ((s = reader.ReadLine ()) != null) { - yield return s; - } - } - } - - public static void AppendAllLines (string path, IEnumerable contents) - { - Path.Validate (path); - - if (contents == null) - return; - - using (TextWriter w = new StreamWriter (path, true)) { - foreach (var line in contents) - w.WriteLine (line); - } - } - - public static void AppendAllLines (string path, IEnumerable contents, Encoding encoding) - { - Path.Validate (path); - - if (contents == null) - return; - - using (TextWriter w = new StreamWriter (path, true, encoding)) { - foreach (var line in contents) - w.WriteLine (line); - } - } - - public static void WriteAllLines (string path, IEnumerable contents) - { - Path.Validate (path); - - if (contents == null) - return; - - using (TextWriter w = new StreamWriter (path, false)) { - foreach (var line in contents) - w.WriteLine (line); - } - } - - public static void WriteAllLines (string path, IEnumerable contents, Encoding encoding) - { - Path.Validate (path); - - if (contents == null) - return; - - using (TextWriter w = new StreamWriter (path, false, encoding)) { - foreach (var line in contents) - w.WriteLine (line); - } - } - - internal static int FillAttributeInfo (String path, ref MonoIOStat data, bool tryagain, bool returnErrorOnNotFound) - { - if (tryagain) - throw new NotImplementedException (); - - MonoIOError error; - MonoIO.GetFileStat (path, out data, out error); - - if (!returnErrorOnNotFound && (error == MonoIOError.ERROR_FILE_NOT_FOUND || error == MonoIOError.ERROR_PATH_NOT_FOUND || error == MonoIOError.ERROR_NOT_READY)) { - data = default (MonoIOStat); - data.fileAttributes = (FileAttributes) (-1); - return 0; - } - - return (int) error; - } -#region Copied from corefx - - internal static DateTimeOffset GetUtcDateTimeOffset(DateTime dateTime) - { - // File and Directory UTC APIs treat a DateTimeKind.Unspecified as UTC whereas - // ToUniversalTime treats this as local. - if (dateTime.Kind == DateTimeKind.Unspecified) - { - return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc); - } - - return dateTime.ToUniversalTime(); - } -#endregion - - } -} diff --git a/mcs/class/corlib/Test/System.IO/FileTest.cs b/mcs/class/corlib/Test/System.IO/FileTest.cs index 4020a5e3a3e1f..bd3cb15916413 100644 --- a/mcs/class/corlib/Test/System.IO/FileTest.cs +++ b/mcs/class/corlib/Test/System.IO/FileTest.cs @@ -356,7 +356,6 @@ public void Copy_SourceFileName_DoesNotExist () Assert.Fail ("#1"); } catch (FileNotFoundException ex) { Assert.AreEqual (typeof (FileNotFoundException), ex.GetType (), "#2"); - Assert.AreEqual ("doesnotexist", ex.FileName, "#3"); Assert.IsNull (ex.InnerException, "#4"); Assert.IsNotNull (ex.Message, "#5"); } @@ -487,7 +486,6 @@ public void Delete_Directory_DoesNotExist () try { File.Delete (path); - Assert.Fail ("#1"); } catch (DirectoryNotFoundException ex) { // Could not find a part of the path "..." Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2"); @@ -849,7 +847,6 @@ public void Move_DestFileName_DirectoryDoesNotExist () Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2"); Assert.IsNull (ex.InnerException, "#3"); Assert.IsNotNull (ex.Message, "#4"); - Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#5"); } } finally { DeleteFile (sourceFile); @@ -857,6 +854,7 @@ public void Move_DestFileName_DirectoryDoesNotExist () } [Test] + [Category("NotWasm")] public void Move_DestFileName_AlreadyExists () { string sourceFile = tmpFolder + Path.DirectorySeparatorChar + "foo"; @@ -873,7 +871,6 @@ public void Move_DestFileName_AlreadyExists () Assert.IsNull (ex.InnerException, "#A3"); Assert.IsNotNull (ex.Message, "#A4"); Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#A5"); - Assert.IsFalse (ex.Message.IndexOf (tmpFolder) != -1, "#A6"); } finally { DeleteFile (sourceFile); } @@ -891,7 +888,6 @@ public void Move_DestFileName_AlreadyExists () Assert.IsNull (ex.InnerException, "#B3"); Assert.IsNotNull (ex.Message, "#B4"); Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#B5"); - Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#B6"); } finally { DeleteFile (sourceFile); DeleteFile (destFile); @@ -910,7 +906,6 @@ public void Move_DestFileName_AlreadyExists () Assert.IsNull (ex.InnerException, "#C3"); Assert.IsNotNull (ex.Message, "#C4"); Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#C5"); - Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#C6"); } finally { DeleteFile (sourceFile); DeleteDirectory (destFile); @@ -1909,32 +1904,6 @@ public void SetCreationTime_Path_DoesNotExist () // } // } - [Test] - public void SetCreationTime_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "CreationTimeIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetCreationTime (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file '...' - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - [Test] public void SetCreationTimeUtc_Path_Null () { @@ -2033,32 +2002,6 @@ public void SetCreationTimeUtc_Path_DoesNotExist () // } // } - [Test] - public void SetCreationTimeUtc_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetCreationTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file "..." - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - // SetLastAccessTime and SetLastAccessTimeUtc exceptions [Test] @@ -2159,32 +2102,6 @@ public void SetLastAccessTime_Path_DoesNotExist () // } // } - [Test] - public void SetLastAccessTime_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "LastAccessIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetLastAccessTime (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file "..." - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - [Test] public void SetLastAccessTimeUtc_Path_Null () { @@ -2283,32 +2200,6 @@ public void SetLastAccessTimeUtc_Path_DoesNotExist () // } // } - [Test] - public void SetLastAccessTimeUtc_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetLastAccessTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file "..." - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - // SetLastWriteTime and SetLastWriteTimeUtc exceptions [Test] @@ -2409,32 +2300,6 @@ public void SetLastWriteTime_Path_DoesNotExist () // } // } - [Test] - public void SetLastWriteTime_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "LastWriteTimeIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetLastWriteTime (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file '...' - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - [Test] public void SetLastWriteTimeUtc_Path_Null () { @@ -2533,32 +2398,6 @@ public void SetLastWriteTimeUtc_Path_DoesNotExist () // } // } - [Test] - public void SetLastWriteTimeUtc_FileLock () - { - string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcIOException1"; - DeleteFile (path); - FileStream stream = null; - try { - stream = File.Create (path); - try { - File.SetLastWriteTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59)); - Assert.Fail ("#1"); - } catch (IOException ex) { - // The process cannot access the file '...' - // because it is being used by another process - Assert.AreEqual (typeof (IOException), ex.GetType (), "#2"); - Assert.IsNull (ex.InnerException, "#3"); - Assert.IsNotNull (ex.Message, "#4"); - Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5"); - } - } finally { - if (stream != null) - stream.Close (); - DeleteFile (path); - } - } - [Test] public void OpenAppend () { @@ -2663,6 +2502,7 @@ public void ReadWriteAllText () } [Test] + [Category("NotWasm")] public void ReplaceTest () { string tmp = Path.Combine (tmpFolder, "ReplaceTest"); @@ -2745,36 +2585,6 @@ void MoveTest (FileAccess acc, FileShare share, bool works) } } - [Test] - public void MoveTest () - { - MoveTest (FileAccess.Read, FileShare.None, false); - MoveTest (FileAccess.Read, FileShare.Read, false); - MoveTest (FileAccess.Read, FileShare.Write, false); - MoveTest (FileAccess.Read, FileShare.ReadWrite, false); - MoveTest (FileAccess.Read, FileShare.Delete, true); - MoveTest (FileAccess.Read, FileShare.Read | FileShare.Delete, true); - MoveTest (FileAccess.Read, FileShare.Write | FileShare.Delete, true); - MoveTest (FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, true); - MoveTest (FileAccess.Write, FileShare.None, false); - MoveTest (FileAccess.Write, FileShare.Read, false); - MoveTest (FileAccess.Write, FileShare.Write, false); - MoveTest (FileAccess.Write, FileShare.ReadWrite, false); - MoveTest (FileAccess.Write, FileShare.Delete, true); - MoveTest (FileAccess.Write, FileShare.Read | FileShare.Delete, true); - MoveTest (FileAccess.Write, FileShare.Write | FileShare.Delete, true); - MoveTest (FileAccess.Write, FileShare.ReadWrite | FileShare.Delete, true); - MoveTest (FileAccess.ReadWrite, FileShare.None, false); - MoveTest (FileAccess.ReadWrite, FileShare.Read, false); - MoveTest (FileAccess.ReadWrite, FileShare.Write, false); - MoveTest (FileAccess.ReadWrite, FileShare.ReadWrite, false); - MoveTest (FileAccess.ReadWrite, FileShare.Delete, true); - MoveTest (FileAccess.ReadWrite, FileShare.Read | FileShare.Delete, true); - MoveTest (FileAccess.ReadWrite, FileShare.Write | FileShare.Delete, true); - MoveTest (FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete, true); - } - - [DllImport ("libc", SetLastError=true)] public static extern int symlink (string oldpath, string newpath); diff --git a/mcs/class/corlib/corefx/File.cs b/mcs/class/corlib/corefx/File.cs new file mode 100644 index 0000000000000..5abd3b2362922 --- /dev/null +++ b/mcs/class/corlib/corefx/File.cs @@ -0,0 +1,31 @@ +using System; +using System.Security.AccessControl; + +namespace System.IO +{ + public partial class File + { + public static FileSecurity GetAccessControl (string path) + { + // AccessControlSections.Audit requires special permissions. + return GetAccessControl (path, + AccessControlSections.Owner | + AccessControlSections.Group | + AccessControlSections.Access); + } + + public static FileSecurity GetAccessControl (string path, AccessControlSections includeSections) + { + return new FileSecurity (path, includeSections); + } + + public static void SetAccessControl (string path, + FileSecurity fileSecurity) + { + if (null == fileSecurity) + throw new ArgumentNullException ("fileSecurity"); + + fileSecurity.PersistModifications (path); + } + } +} \ No newline at end of file diff --git a/mcs/class/corlib/corefx/SR.cs b/mcs/class/corlib/corefx/SR.cs index 360494e5e58ac..c924ca12f5eed 100644 --- a/mcs/class/corlib/corefx/SR.cs +++ b/mcs/class/corlib/corefx/SR.cs @@ -1536,4 +1536,5 @@ partial class SR public const string Arg_FileIsDirectory_Name = "The target file '{0}' is a directory, not a file."; public const string Arg_PathIsVolume = "Path must not be a drive."; public const string IO_FileCreateAlreadyExists = "Cannot create a file when that file already exists."; + public const string PlatformNotSupported_FileEncryption = "File encryption is not supported on this platform."; } diff --git a/mcs/class/corlib/corlib.csproj b/mcs/class/corlib/corlib.csproj index accab198587ed..c44908964202e 100644 --- a/mcs/class/corlib/corlib.csproj +++ b/mcs/class/corlib/corlib.csproj @@ -738,10 +738,13 @@ + + + @@ -1385,7 +1388,6 @@ - @@ -2026,6 +2028,7 @@ + @@ -2069,6 +2072,7 @@ + @@ -2088,6 +2092,7 @@ + @@ -2132,6 +2137,7 @@ + @@ -2258,6 +2264,7 @@ + @@ -2277,6 +2284,7 @@ + @@ -2328,6 +2336,7 @@ + @@ -2347,6 +2356,7 @@ + @@ -2398,6 +2408,7 @@ + @@ -2417,6 +2428,7 @@ + @@ -2471,6 +2483,7 @@ + @@ -2595,6 +2608,7 @@ + @@ -2623,6 +2637,7 @@ + @@ -2667,6 +2682,7 @@ + @@ -2695,6 +2711,7 @@ + @@ -2739,6 +2756,7 @@ + @@ -2767,6 +2785,7 @@ + @@ -2814,6 +2833,7 @@ + @@ -2833,6 +2853,7 @@ + @@ -2881,6 +2902,7 @@ + @@ -2900,6 +2922,7 @@ + @@ -2948,6 +2971,7 @@ + @@ -2967,6 +2991,7 @@ + @@ -3015,6 +3040,7 @@ + @@ -3034,6 +3060,7 @@ + diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index e6e5cbb476202..f0bb1021d3853 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -201,12 +201,14 @@ System.Globalization/RegionInfo.cs System.Globalization/RegionInfo.MonoTouch.cs System.IO/DriveInfo.cs ../../../external/corefx/src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveType.cs -System.IO/File.cs +../../../external/corefx/src/System.IO.FileSystem/src/System/IO/File.cs ../../../external/corefx/src/Common/src/CoreLib/System/IO/FileAccess.cs ../../../external/corefx/src/System.Runtime/src/System/IO/FileAttributes.cs ../../../external/corefx/src/Common/src/CoreLib/System/IO/FileMode.cs ../../../external/corefx/src/Common/src/CoreLib/System/IO/FileOptions.cs ../../../external/corefx/src/Common/src/CoreLib/System/IO/FileShare.cs +../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Iterator.cs +../../../external/corefx/src/System.IO.FileSystem/src/System/IO/ReadLinesIterator.cs System.IO/FileStream.cs System.IO/FileStreamAsyncResult.cs System.IO/HGlobalUnmanagedMemoryStream.cs @@ -1881,4 +1883,5 @@ corefx/Mono.SafePasswordHandle.Unix.cs corefx/DirectoryInfo.cs corefx/FileInfo.cs corefx/Directory.cs -corefx/MonoLinqHelper.cs \ No newline at end of file +corefx/MonoLinqHelper.cs +corefx/File.cs \ No newline at end of file diff --git a/mcs/class/corlib/corlib_xtest.dll.sources b/mcs/class/corlib/corlib_xtest.dll.sources index 655c470e4651d..2a24436b2d146 100644 --- a/mcs/class/corlib/corlib_xtest.dll.sources +++ b/mcs/class/corlib/corlib_xtest.dll.sources @@ -370,12 +370,7 @@ ../../../external/corefx/src/CoreFx.Private.TestUtilities/src/System/AdminHelpers.cs ../../../external/corefx/src/CoreFx.Private.TestUtilities/src/System/TheoryExtensions.cs ../../../external/corefx/src/System.IO.FileSystem/tests/Base/*.cs:StaticGetSetTimes.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/ReadWriteAllText.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Copy.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Create.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Delete.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Move.cs +../../../external/corefx/src/System.IO.FileSystem/tests/File/*.cs:GetSetTimes.cs ../../../external/corefx/src/System.IO.FileSystem/tests/FileStream/ctor_*.cs ../../../external/corefx/src/System.IO.FileSystem/tests/PortedCommon/*.cs ../../../external/corefx/src/System.IO.FileSystem/tests/FileSystemTest.cs diff --git a/mcs/class/corlib/unix_build_corlib.dll.sources b/mcs/class/corlib/unix_build_corlib.dll.sources index 5999d1944a7a7..3c248f4294ee2 100644 --- a/mcs/class/corlib/unix_build_corlib.dll.sources +++ b/mcs/class/corlib/unix_build_corlib.dll.sources @@ -2,6 +2,7 @@ ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.Unix.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs +../../../external/corefx/src/Common/src/CoreLib/Internal/IO/File.Unix.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.Unix.cs ../../../external/corefx/src/Common/src/CoreLib/System/IO/PathInternal.Unix.cs @@ -20,6 +21,7 @@ ../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.ChMod.cs ../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs ../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.UTime.cs +../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.UTimes.cs ../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.RmDir.cs ../../../external/corefx/src/Common/src/Interop/Unix/System.Native/Interop.MountPoints.cs ../../../external/corefx/src/Common/src/CoreLib/Interop/Unix/System.Native/Interop.ReadDir.cs diff --git a/mcs/class/corlib/wasm_corlib_xtest.dll.exclude.sources b/mcs/class/corlib/wasm_corlib_xtest.dll.exclude.sources index 2926befb62091..e6224c02c75d7 100644 --- a/mcs/class/corlib/wasm_corlib_xtest.dll.exclude.sources +++ b/mcs/class/corlib/wasm_corlib_xtest.dll.exclude.sources @@ -25,20 +25,15 @@ ../../../external/corefx/src/System.IO.FileSystem/tests/FSAssert.cs ../../../external/corefx/src/CoreFx.Private.TestUtilities/src/System/AdminHelpers.cs ../../../external/corefx/src/CoreFx.Private.TestUtilities/src/System/TheoryExtensions.cs -../../../external/corefx/src/System.IO.FileSystem/tests/Base/*.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/ReadWriteAllLines.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/ReadWriteAllText.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Copy.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Create.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Delete.cs -../../../external/corefx/src/System.IO.FileSystem/tests/File/Move.cs +../../../external/corefx/src/System.IO.FileSystem/tests/Base/*.cs:StaticGetSetTimes.cs +../../../external/corefx/src/System.IO.FileSystem/tests/File/*.cs:GetSetTimes.cs ../../../external/corefx/src/System.IO.FileSystem/tests/FileStream/ctor_*.cs ../../../external/corefx/src/System.IO.FileSystem/tests/PortedCommon/*.cs ../../../external/corefx/src/System.IO.FileSystem/tests/FileSystemTest.cs -../../../external/corefx/src/System.IO.FileSystem/tests/FileInfo/*.cs +../../../external/corefx/src/System.IO.FileSystem/tests/FileInfo/*.cs:GetSetTimes.cs # System.IO.Directory -../../../external/corefx/src/System.IO.FileSystem/tests/Directory/*.cs +../../../external/corefx/src/System.IO.FileSystem/tests/Directory/*.cs:GetSetTimes.cs # System.IO.DirectoryInfo -../../../external/corefx/src/System.IO.FileSystem/tests/DirectoryInfo/*.cs +../../../external/corefx/src/System.IO.FileSystem/tests/DirectoryInfo/*.cs:GetSetTimes.cs diff --git a/mcs/class/corlib/win32_build_corlib.dll.sources b/mcs/class/corlib/win32_build_corlib.dll.sources index 28e77a972bd8d..b17f90f7720b0 100644 --- a/mcs/class/corlib/win32_build_corlib.dll.sources +++ b/mcs/class/corlib/win32_build_corlib.dll.sources @@ -53,6 +53,7 @@ ../../../external/corefx/src/Common/src/Interop/Windows/kernel32/Interop.FindFirstFileEx.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.Windows.cs +../../../external/corefx/src/Common/src/CoreLib/Internal/IO/File.Windows.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Windows.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEnumerator.Win32.cs ../../../external/corefx/src/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.Windows.cs diff --git a/sdks/wasm/driver.c b/sdks/wasm/driver.c index 58a7c8a4c1157..07e9a8898b8a7 100644 --- a/sdks/wasm/driver.c +++ b/sdks/wasm/driver.c @@ -32,6 +32,7 @@ void SystemNative_GetTimebaseInfo (); void SystemNative_GetTimestamp (); void SystemNative_GetTimestampResolution (); void SystemNative_UTime (); +void SystemNative_UTimes (); void SystemNative_Access (); void SystemNative_ChDir (); void SystemNative_ChMod (); @@ -155,6 +156,7 @@ static PinvokeImport sysnative_imports [] = { {"SystemNative_GetTimestamp", SystemNative_GetTimestamp}, {"SystemNative_GetTimestampResolution", SystemNative_GetTimestampResolution}, {"SystemNative_UTime", SystemNative_UTime}, + {"SystemNative_UTimes", SystemNative_UTimes}, {"SystemNative_Access", SystemNative_Access}, {"SystemNative_ChDir", SystemNative_ChDir}, {"SystemNative_ChMod", SystemNative_ChMod},