Пример #1
0
        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));
            }
        }
Пример #2
0
 internal ImageFile(Camera camera, FileSystem fs, string metadata, string directory, string filename, bool local)
     : base(camera, fs, metadata, directory, filename, local)
 {
 }
Пример #3
0
        internal static File Create(Camera camera, FileSystem fs, string directory, string filename)
        {
            LibGPhoto2.CameraFile metadataFile;
            string metadata = null;
            string mime = GuessMimetype(filename);
            LibGPhoto2.CameraFileType type = LibGPhoto2.CameraFileType.MetaData;
            string fullDirectory = FileSystem.CombinePath(fs.BaseDirectory, directory);

            using (metadataFile = camera.Device.GetFile(fullDirectory, filename, type, camera.Context))
                metadata = Encoding.UTF8.GetString(metadataFile.GetDataAndSize());

            /* First check to see if it's a music file */
            if (mime ==  LibGPhoto2.MimeTypes.MP3 ||
                mime ==  LibGPhoto2.MimeTypes.WMA ||
                mime ==  LibGPhoto2.MimeTypes.WAV ||
                mime ==  LibGPhoto2.MimeTypes.OGG)
            {
                return new MusicFile(camera, fs, metadata, directory, filename, false);
            }

            /* Second check to see if it's an image */
            if(mime ==  LibGPhoto2.MimeTypes.BMP ||
               mime ==  LibGPhoto2.MimeTypes.JPEG ||
               mime ==  LibGPhoto2.MimeTypes.PNG ||
               mime ==  LibGPhoto2.MimeTypes.RAW ||
               mime ==  LibGPhoto2.MimeTypes.TIFF)
            {
                return new ImageFile(camera, fs, metadata, directory, filename, false);
            }

            /* Third check to see if it's a playlist */
            if(filename.EndsWith(".zpl"))
            {
                // A playlist needs the actual data to work correctly as opposed to the metadata
                // this data is grabbed in the Playlist constructor
                return new PlaylistFile(camera, fs, metadata, directory, filename, false);
            }

            return new GenericFile(camera, fs, metadata, directory, filename, false);
        }
Пример #4
0
        /// <summary>
        /// Creates a new File
        /// </summary>
        /// <param name="camera">The camera this file is on (null if the file is a local file)
        /// A <see cref="Camera"/>
        /// </param>
        /// <param name="fs">The filesystem this file is on (null if the file is a local file)
        /// A <see cref="FileSystem"/>
        /// </param>
        /// <param name="metadata">The metadata for this file (string.Empty if there is none)
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="path">The path to this file
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="filename">The filename
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="local">True if the file is on the local filesystem, false if the file is on the camera
        /// A <see cref="System.Boolean"/>
        /// </param>
        protected File(Camera camera, FileSystem fs, string metadata, string path, string filename, bool local)
        {
            if(metadata == null)
                throw new ArgumentNullException("metadata");

            this.camera = camera;
            this.fileName = filename;
            this.filesystem = fs;
            this.localFile = local;
            this.path = path;
            this.metadata = new Dictionary<string, string>();
            this.mimetype = GuessMimetype(filename);
            ParseMetadata(metadata);

            if(local && !string.IsNullOrEmpty(filename))
                size = new FileInfo(System.IO.Path.Combine(path, filename)).Length;
            else
                size = (long)camera.Device.GetFileInfo(FileSystem.CombinePath(fs.BaseDirectory, path), filename, camera.Context).file.size;
        }
Пример #5
0
 internal GenericFile(Camera camera, FileSystem fs, string metadata, string path, string filename, bool local)
     : base(camera, fs, metadata, path, filename, local)
 {
 }
Пример #6
0
 internal FileSystem(Camera camera, LibGPhoto2.CameraStorageInformation storage)
 {
     this.camera = camera;
     this.storage = storage;
 }