private iPhoneFile(iPhone phone, long handle, OpenMode mode) : base() { this.phone = phone; this.mode = mode; this.handle = handle; }
public static unsafe iPhoneFile Open(iPhone phone, string path, FileAccess openmode) { long num2; OpenMode none = OpenMode.None; switch (openmode) { case FileAccess.Read: none = OpenMode.Read; break; case FileAccess.Write: none = OpenMode.Write; break; case FileAccess.ReadWrite: throw new NotImplementedException("Read+Write not (yet) implemented"); } string str = phone.FullPath(phone.CurrentDirectory, path); int num = MobileDevice.AFCFileRefOpen(phone.AFCHandle, str, (int) none, 0, out num2); if (num != 0) { phone.ReConnect(); throw new IOException("AFCFileRefOpen failed with error " + num.ToString()); } return new iPhoneFile(phone, num2, none); }
/// <summary> /// Constructor /// </summary> /// <param name="iphone">iDevice to map to drive letter</param> public iPhoneFS(iPhone iphone) { iDevice = iphone; LetterString = iDevice.DriveLetter.ToString().ToUpper() + ":> "; Debugger.Log(LetterString + "EVENT: FileSystem initialized.", Debugger.LogLevel.Event); if (iDevice.IsJailbreak) { iDeviceMedia = new iPhone_ForceAFC(iDevice); Debugger.Log(LetterString + "EVENT: iDevice jailbroken. Connecting to afc service.", Debugger.LogLevel.Event); } }
public FileDialog(iPhone iDeviceInterface) { InitializeComponent(); _fixChars = Path.GetInvalidFileNameChars(); _unfixChars = Path.GetInvalidFileNameChars(); Array.Sort(_unfixChars); Array.Reverse(_unfixChars); _iDeviceInterface = iDeviceInterface; _timer = new System.Timers.Timer(); _timer.Interval = 1000; _timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed); }
// TODO: MOVE THIS INTO IPHONE CLASS public static void CopyFileFromDevice(iPhone iDeviceInterface, string source, string destination, Action<ulong> bytesTransfered, Func<bool> cancelled) { // remove our local file if it exists if (File.Exists(destination)) { File.Delete(destination); } // make sure the source file exists if (iDeviceInterface.Exists(source)) { using (iPhoneFile from = iPhoneFile.OpenRead(iDeviceInterface, source)) using (FileStream to = File.OpenWrite(destination)) { Utilities.Copy(from, to, bytesTransfered, cancelled); } } }
public static void CopyFileToDevice(iPhone iDeviceInterface, string source, string destination, Action<ulong> bytesTransfered, Func<bool> cancelled) { if (source.Equals("Thumbs.db") || source.Equals(".DS_Store")) { return; } // if it already exists if (iDeviceInterface.Exists(destination)) { // TODO: DO SOMETHING WHEN THE FILE ALREADY EXISTS } if (File.Exists(source)) { using (FileStream from = File.OpenRead(source)) using (iPhoneFile to = iPhoneFile.OpenWrite(iDeviceInterface, destination)) { Utilities.Copy(from, to, bytesTransfered, cancelled); } } }
/// <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(iPhone phone, string path) { return iPhoneFile.Open(phone, path, FileAccess.Write); }
/// <summary> /// Opens a file for reading /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to be opened for reading</param> /// <returns>An unshared <c>iPhoneFile</c> object on the specified path with Write access. </returns> public static iPhoneFile OpenRead(iPhone phone, string path) { return iPhoneFile.Open(phone, path, FileAccess.Read); }
/// <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 unsafe iPhoneFile Open(iPhone 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.AFCFileRefOpen(phone.AFCHandle, full_path, (int)mode, 0, out handle); if (ret != 0) { phone.ReConnect(); throw new IOException("AFCFileRefOpen failed with error " + ret.ToString()); } return new iPhoneFile(phone, handle, mode); }
/// <summary> /// The default constructor, in this case very simple, just set the path of the directory to share /// </summary> public iPhoneFS() { phone = new iPhone(); }
public Boolean AddFileType( // for FileType Adds String name, iPhone.FileTypes type, String imageKey, String tag ) { return Add(name, type, TypeIdentifier.FileType, null, nullBytes, 0, imageKey, tag); }
public Boolean Add( // The Generic ADD String name, iPhone.FileTypes type, TypeIdentifier typeID, String fileInfoText, Byte[] headerBytes, Int32 byteOffset, String imageKey, String tag ) { ItemProperty newItem = new ItemProperty(); newItem.Name = name; newItem.Type = type; newItem.Identifier = typeID; newItem.FileInfoText = fileInfoText; newItem.Header = headerBytes; newItem.ByteOffset = byteOffset; newItem.ImageKey = imageKey; newItem.Tag = tag; items.Add(newItem); selectedIndex = items.Count - 1; return true; }
/// <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(iPhone phone, string path) { return(iPhoneFile.Open(phone, path, FileAccess.Write)); }
/// <summary> /// Opens a file for reading /// </summary> /// <param name="phone">A valid iPhone object</param> /// <param name="path">The file to be opened for reading</param> /// <returns>An unshared <c>iPhoneFile</c> object on the specified path with Write access. </returns> public static iPhoneFile OpenRead(iPhone phone, string path) { return(iPhoneFile.Open(phone, path, FileAccess.Read)); }
/// <summary> /// Creates a new iPhone object. If an iPhone is connected to the computer, a connection will automatically be opened. /// </summary> public unsafe iPhone_ForceAFC(iPhone Device) { iPhoneHandle = Device.Device; ConnectToPhone(); }
public Boolean AddPath( // for fixed pathname - can be file or folder String name, iPhone.FileTypes type, String folderInfoText, String imageKey, String tag ) { return Add(name, type, TypeIdentifier.FullPath, folderInfoText, nullBytes, 0, imageKey, tag); }
private void Tester_Load(object sender, EventArgs e) { phone = new iPhone(); phone.Connect += new ConnectEventHandler(phone_Connect); }