public static IByteDevice Create(Uri.Locator resource) { IByteDevice result = ByteDevice.Open(resource, System.IO.FileMode.Create); if (result.IsNull() && resource.NotNull()) { System.IO.Directory.CreateDirectory(resource.Path.FolderPath.PlatformPath); result = ByteDevice.Open(resource, System.IO.FileMode.Create); } return(result); }
static IByteDevice Open(Uri.Locator resource, System.IO.FileMode mode) { IByteDevice result = null; if (resource.NotNull()) { switch (resource.Scheme) { case "assembly": result = resource.Authority == "" ? ByteDevice.Open(System.Reflection.Assembly.GetEntryAssembly(), resource.Path) : ByteDevice.Open(System.Reflection.Assembly.Load(new System.Reflection.AssemblyName(resource.Authority)), resource.Path); break; case "file": try { System.IO.FileStream stream = System.IO.File.Open(System.IO.Path.GetFullPath(resource.PlatformPath), mode, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite); if (stream.NotNull()) { result = new ByteDevice(stream, resource); } } catch (System.IO.DirectoryNotFoundException) { result = null; } catch (System.IO.FileNotFoundException) { result = null; } break; case "http": case "https": if (mode == System.IO.FileMode.Open) { // TODO: support http and https. } break; } } return(result); }
public static IByteDevice Open(Uri.Locator input, Uri.Locator output) { return(ByteDeviceCombiner.Open(ByteDevice.Open(input), ByteDevice.Create(output))); }
public static IByteDevice Open(Uri.Locator resource) { return(ByteDevice.Open(resource, System.IO.FileMode.Open)); }
public static IByteDevice Open(System.IO.Stream input, System.IO.Stream output) { return(ByteDeviceCombiner.Open(ByteDevice.Open(input), ByteDevice.Open(output))); }
public static ICharacterDevice Open(Uri.Locator resource) { return(CharacterDevice.Open(ByteDevice.Open(resource))); }
public static ICharacterDevice Open(System.IO.Stream stream) { return(CharacterDevice.Open(ByteDevice.Open(stream))); }