private iPhoneFile(MobileDeviceInstance phone, long handle, OpenMode mode) : base() { this.phone = phone; this.mode = mode; this.handle = handle; }
/// <summary> /// Opens an iPhoneFile stream on the specified path /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to open</param> /// <param name="openmode">A <see cref="FileAccess"/> value that specifies the operations that can be performed on the file</param> /// <returns></returns> public static iPhoneFile Open(MobileDeviceInstance phone, string path, FileAccess openmode) { OpenMode mode; int ret; long handle; string full_path; mode = OpenMode.None; switch (openmode) { case FileAccess.Read: mode = OpenMode.Read; break; case FileAccess.Write: mode = OpenMode.Write; break; case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented"); } full_path = phone.FullPath(phone.CurrentDirectory, path); ret = MobileDevice.DeviceImpl.FileRefOpen(phone.AFCHandle, full_path, (Int64)mode, out handle); if (ret != 0) { phone.Reconnect(); // error codes and their meaning // 7 - bad path // 18 - out of disk space throw new IOException("AFCFileRefOpen (" + full_path + ") failed with error " + ret.ToString()); } return(new iPhoneFile(phone, handle, mode)); }
private static void NotifyCallback(ref AMDeviceNotificationCallbackInfo callback) { if (callback.msg == NotificationMessage.Connected) { MobileDeviceInstance Inst; if (ConnectedDevices.TryGetValue(callback.dev, out Inst)) { // Already connected, not sure why we got another message... } else { Inst = new MobileDeviceInstance(callback.dev); ConnectedDevices.Add(callback.dev, Inst); } if (Inst.ConnectToPhone()) { OnConnect(new ConnectEventArgs(callback)); } } else if (callback.msg == NotificationMessage.Disconnected) { MobileDeviceInstance Inst; if (ConnectedDevices.TryGetValue(callback.dev, out Inst)) { Inst.connected = false; OnDisconnect(new ConnectEventArgs(callback)); ConnectedDevices.Remove(callback.dev); } } }
/// <summary> /// Opens a file for writing /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to be opened for writing</param> /// <returns>An unshared <c>iPhoneFile</c> object on the specified path with Write access. </returns> public static iPhoneFile OpenWrite(MobileDeviceInstance phone, string path) { return(iPhoneFile.Open(phone, path, FileAccess.Write)); }
/// <summary> /// Opens a file for writing /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to be opened for writing</param> /// <returns>An unshared <c>iPhoneFile</c> object on the specified path with Write access. </returns> public static iPhoneFile OpenWrite(MobileDeviceInstance phone, string path) { return iPhoneFile.Open(phone, path, FileAccess.Write); }
/// <summary> /// Opens an iPhoneFile stream on the specified path /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to open</param> /// <param name="openmode">A <see cref="FileAccess"/> value that specifies the operations that can be performed on the file</param> /// <returns></returns> public static iPhoneFile Open(MobileDeviceInstance phone, string path, FileAccess openmode) { OpenMode mode; int ret; long handle; string full_path; mode = OpenMode.None; switch (openmode) { case FileAccess.Read: mode = OpenMode.Read; break; case FileAccess.Write: mode = OpenMode.Write; break; case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented"); } full_path = phone.FullPath(phone.CurrentDirectory, path); ret = MobileDevice.DeviceImpl.FileRefOpen(phone.AFCHandle, full_path, (Int64)mode, out handle); if (ret != 0) { phone.Reconnect(); throw new IOException("AFCFileRefOpen failed with error " + ret.ToString()); } return new iPhoneFile(phone, handle, mode); }
/// <summary> /// Opens an iPhoneFile stream on the specified path /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to open</param> /// <param name="openmode">A <see cref="FileAccess"/> value that specifies the operations that can be performed on the file</param> /// <returns></returns> public static iPhoneFile Open(MobileDeviceInstance phone, string path, FileAccess openmode) { OpenMode mode; int ret; long handle; string full_path; mode = OpenMode.None; switch (openmode) { case FileAccess.Read: mode = OpenMode.Read; break; case FileAccess.Write: mode = OpenMode.Write; break; case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented"); } full_path = phone.FullPath(phone.CurrentDirectory, path); ret = MobileDevice.DeviceImpl.FileRefOpen(phone.AFCHandle, MobileDevice.StringToFileSystemRepresentation(full_path), (Int64)mode, out handle); if (ret != 0) { phone.Reconnect(); // error codes and their meaning // 7 - bad path // 18 - out of disk space throw new IOException("AFCFileRefOpen (" + full_path + ") failed with error " + ret.ToString()); } return new iPhoneFile(phone, handle, mode); }