using System.Text;
using System.Runtime.InteropServices;
-#if !NET_2_1
+#if !MOBILE
using System.Security.AccessControl;
#endif
}
}
+ 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);
FileShare.None, bufferSize);
}
-#if !NET_2_1
[MonoLimitation ("FileOptions are ignored")]
public static FileStream Create (string path, int bufferSize,
FileOptions options)
{
- return Create (path, bufferSize, options, null);
+ return new FileStream (path, FileMode.Create, FileAccess.ReadWrite,
+ FileShare.None, bufferSize, options);
}
-
+
+#if !MOBILE
[MonoLimitation ("FileOptions and FileSecurity are ignored")]
public static FileStream Create (string path, int bufferSize,
FileOptions options,
return MonoIO.ExistsFile (path, out error);
}
-#if !NET_2_1
+#if !MOBILE
public static FileSecurity GetAccessControl (string path)
{
// AccessControlSections.Audit requires special permissions.
"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);
}
}
-#if !NET_2_1
+#if !MOBILE
public static void SetAccessControl (string path,
FileSecurity fileSecurity)
{
public static void WriteAllText (string path, string contents)
{
- WriteAllText (path, contents, Encoding.UTF8Unmarked);
+ WriteAllText (path, contents, EncodingHelper.UTF8Unmarked);
}
public static void WriteAllText (string path, string contents, Encoding encoding)
throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system."));
}
-#if NET_4_0
public static IEnumerable<string> ReadLines (string path)
{
return ReadLines (File.OpenText (path));
w.WriteLine (line);
}
}
-#endif
+
+ 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;
+ }
}
}