Exemple #1
0
        /// <summary>
        /// Gets a file entry from the specified path on the device.
        /// </summary>
        /// <param name="device">The device to check</param>
        /// <param name="path">the path to check</param>
        /// <exception cref="IOException">If the device is not connected.</exception>
        /// <exception cref="ArgumentNullException">If the device or path is null.</exception>
        /// <exception cref="FileNotFoundException">If the entrty is not found.</exception>
        /// <returns></returns>
        public static FileEntry Find(IDevice device, FileListingService fileListingService, String path)
        {
            device.ThrowIfNull("device");
            path.ThrowIfNullOrEmpty("path");

            if (!device.IsOffline)
            {
                return(fileListingService.FindFileEntry(path));
            }
            else
            {
                throw new IOException("Device is not online");
            }
        }
Exemple #2
0
        /// <summary>
        /// Finds the file entry, or creates an empty FileEntry if it does not exist.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="path">The path.</param>
        /// <remarks>This does not create the FileEntry on disk. It only creates the FileEntry object.</remarks>
        /// <returns></returns>
        public static FileEntry FindOrCreate(IDevice device, FileListingService fileListingService, String path)
        {
            device.ThrowIfNull("device");
            path.ThrowIfNullOrEmpty("path");

            if (!device.IsOffline)
            {
                try
                {
                    return(fileListingService.FindFileEntry(path));
                }
                catch (FileNotFoundException)
                {
                    var fe = new FileEntry(device, path);
                    fe.Create();
                    return(fe);
                }
            }
            else
            {
                throw new IOException("Device is not online");
            }
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileSystem"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public FileSystem(IDevice device)
 {
     Device = device;
     this.fileListingService = new FileListingService(device);
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FileSystem"/> class.
 /// </summary>
 /// <param name="device">The device.</param>
 public FileSystem(IDevice device)
 {
     Device = device;
     this.fileListingService = new FileListingService(device);
 }