Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
 public static IByteDevice Open(Uri.Locator input, Uri.Locator output)
 {
     return(ByteDeviceCombiner.Open(ByteDevice.Open(input), ByteDevice.Create(output)));
 }
Example #4
0
 public static IByteDevice Open(Uri.Locator resource)
 {
     return(ByteDevice.Open(resource, System.IO.FileMode.Open));
 }
Example #5
0
 public static IByteDevice Open(System.IO.Stream input, System.IO.Stream output)
 {
     return(ByteDeviceCombiner.Open(ByteDevice.Open(input), ByteDevice.Open(output)));
 }
Example #6
0
 public static ICharacterDevice Open(Uri.Locator resource)
 {
     return(CharacterDevice.Open(ByteDevice.Open(resource)));
 }
Example #7
0
 public static ICharacterDevice Open(System.IO.Stream stream)
 {
     return(CharacterDevice.Open(ByteDevice.Open(stream)));
 }