/// <summary> /// Creates a new file from the supplied stream /// </summary> /// <param name="stream">The stream containing the file data /// A <see cref="Stream"/> /// </param> // public File (Stream stream) // : this(null, null, "", null, null, true) // { // if (stream == null) // throw new ArgumentNullException("stream"); // // this.stream = stream; // this.size = stream.Length; // } /// <summary> /// Reads the entire file and returns it as a byte array /// </summary> /// <returns> /// A <see cref="System.Byte"/> /// </returns> private byte[] DownloadBytes() { if (LocalFile) { throw new InvalidOperationException("This file is already on the local filesystem"); } string fullPath = FileSystem.CombinePath(filesystem.BaseDirectory, path); using (LibGPhoto2.CameraFile file = camera.Device.GetFile(fullPath, fileName, LibGPhoto2.CameraFileType.Normal, camera.Context)) return(file.GetDataAndSize()); }
internal PlaylistFile(Camera camera, FileSystem fsystem, string metadata, string directory, string filename, bool local) : base(camera, fsystem, metadata, directory, filename, local) { string file; string filesystem; files = new List <Gphoto2.File>(); string fullDirectory = FileSystem.CombinePath(fsystem.BaseDirectory, directory); // The 'data' is a list of full filepaths seperated by newlines using (LibGPhoto2.CameraFile camfile = camera.Device.GetFile(fullDirectory, filename, LibGPhoto2.CameraFileType.Normal, camera.Context)) metadata = System.Text.Encoding.UTF8.GetString(camfile.GetDataAndSize()); StringReader r = new StringReader(metadata); while ((file = r.ReadLine()) != null) { FileSystem.SplitPath(file, out filesystem, out directory, out filename); FileSystem fs = camera.FileSystems.Find(delegate(FileSystem filesys) { return(filesys.BaseDirectory == filesystem); }); files.Add(File.Create(camera, fs, directory, filename)); } }