Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -195,11 +195,18 @@ namespace System.IO
// on Moonlight this does not throw but returns false
if (!SecurityManager.CheckElevatedPermissions ())
return false;
string full_path;
try {
full_path = Path.GetFullPath (path);
} catch {
return false;
}
MonoIOError error;
bool exists;
exists = MonoIO.ExistsDirectory (path, out error);
exists = MonoIO.ExistsDirectory (full_path, out error);
/* This should not throw exceptions */
return exists;
}

View File

@@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.IO {
@@ -12,13 +13,14 @@ namespace System.IO {
const string LibLog = "/system/lib/liblog.so";
const string LibLog64 = "/system/lib64/liblog.so";
readonly byte[] appname;
TextWriter stdout;
readonly string appname;
StringBuilder line = new StringBuilder ();
public LogcatTextWriter (string appname, TextWriter stdout)
{
this.appname = appname;
this.appname = Encoding.UTF8.GetBytes (appname);
this.stdout = stdout;
}
@@ -46,34 +48,22 @@ namespace System.IO {
var o = line.ToString ();
line.Clear ();
Log (LogLevel.Info, appname, o);
unsafe {
fixed (byte *b_appname = appname)
fixed (byte *b_message = Encoding.UTF8.GetBytes(o)) {
Log (b_appname, 1 << 5 /* G_LOG_LEVEL_MESSAGE */, b_message);
}
}
stdout.WriteLine (o);
}
enum LogLevel {
Unknown,
Default,
Verbose,
Debug,
Info,
Warn,
Error,
Fatal,
Silent
}
public static bool IsRunningOnAndroid ()
{
return File.Exists (LibLog) || File.Exists (LibLog64);
}
[DllImport ("liblog")]
static extern void __android_log_print (LogLevel level, string appname, string format, string args, IntPtr zero);
static void Log (LogLevel level, string appname, string log)
{
__android_log_print (level, appname, "%s", log, IntPtr.Zero);
}
[MethodImpl(MethodImplOptions.InternalCall)]
static unsafe extern void Log (byte *appname, int level, byte *message);
}
}

View File

@@ -169,44 +169,135 @@ namespace System.IO
// directory methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool CreateDirectory (string path, out MonoIOError error);
private unsafe extern static bool CreateDirectory (char* path, out MonoIOError error);
public static bool CreateDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return CreateDirectory (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool RemoveDirectory (string path, out MonoIOError error);
private unsafe extern static bool RemoveDirectory (char* path, out MonoIOError error);
public static bool RemoveDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return RemoveDirectory (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string GetCurrentDirectory (out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool SetCurrentDirectory (string path, out MonoIOError error);
private unsafe extern static bool SetCurrentDirectory (char* path, out MonoIOError error);
public static bool SetCurrentDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return SetCurrentDirectory (pathChars, out error);
}
}
}
// file methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool MoveFile (string path, string dest,
out MonoIOError error);
private unsafe extern static bool MoveFile (char* path, char* dest,
out MonoIOError error);
public static bool MoveFile (string path, string dest,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path, destChars = dest) {
return MoveFile (pathChars, destChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool CopyFile (string path, string dest,
bool overwrite,
out MonoIOError error);
private unsafe extern static bool CopyFile (char* path, char* dest,
bool overwrite,
out MonoIOError error);
public static bool CopyFile (string path, string dest,
bool overwrite,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path, destChars = dest) {
return CopyFile (pathChars, destChars, overwrite, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool DeleteFile (string path,
out MonoIOError error);
private unsafe extern static bool DeleteFile (char* path,
out MonoIOError error);
public static bool DeleteFile (string path,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return DeleteFile (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool ReplaceFile (string sourceFileName,
string destinationFileName,
string destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error);
private unsafe extern static bool ReplaceFile (char* sourceFileName,
char* destinationFileName,
char* destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error);
public static bool ReplaceFile (string sourceFileName,
string destinationFileName,
string destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error)
{
unsafe {
fixed (char* sourceFileNameChars = sourceFileName,
destinationFileNameChars = destinationFileName,
destinationBackupFileNameChars = destinationBackupFileName) {
return ReplaceFile (sourceFileNameChars, destinationFileNameChars, destinationBackupFileNameChars, ignoreMetadataErrors, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static FileAttributes GetFileAttributes (string path, out MonoIOError error);
private unsafe extern static FileAttributes GetFileAttributes (char* path, out MonoIOError error);
public static FileAttributes GetFileAttributes (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return GetFileAttributes (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool SetFileAttributes (string path, FileAttributes attrs, out MonoIOError error);
private extern static bool SetFileAttributes (char* path, FileAttributes attrs, out MonoIOError error);
public static bool SetFileAttributes (string path, FileAttributes attrs, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return SetFileAttributes (pathChars, attrs, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static MonoFileType GetFileType (IntPtr handle, out MonoIOError error);
@@ -228,7 +319,16 @@ namespace System.IO
//
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr FindFirstFile (string path_with_pattern, out string fileName, out int fileAttr, out int error);
private unsafe extern static IntPtr FindFirstFile (char* pathWithPattern, out string fileName, out int fileAttr, out int error);
public static IntPtr FindFirstFile (string pathWithPattern, out string fileName, out int fileAttr, out int error)
{
unsafe {
fixed (char* pathWithPatternChars = pathWithPattern) {
return FindFirstFile (pathWithPatternChars, out fileName, out fileAttr, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool FindNextFile (IntPtr hnd, out string fileName, out int fileAttr, out int error);
@@ -294,19 +394,44 @@ namespace System.IO
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool GetFileStat (string path,
out MonoIOStat stat,
out MonoIOError error);
private unsafe extern static bool GetFileStat (char* path,
out MonoIOStat stat,
out MonoIOError error);
public static bool GetFileStat (string path,
out MonoIOStat stat,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return GetFileStat (pathChars, out stat, out error);
}
}
}
// handle methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr Open (string filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error);
private unsafe extern static IntPtr Open (char* filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error);
public static IntPtr Open (string filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error)
{
unsafe {
fixed (char* filenameChars = filename) {
return Open (filenameChars, mode, access, share, options, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool Close (IntPtr handle,