/// <summary> /// Determines whether a file or directory exists on an Xbox. /// </summary> /// <param name="systemIpAddress">The "System Ip" address of the Xbox kit.</param> /// <param name="path">The file or directory to look for.</param> /// <param name="additionalExistsPredicate">The optional additional logic to determine existence based on XboxFileSystemInfoDefinition.</param> /// <param name="consoleAdapter">The Xbox console to search on.</param> /// <returns>A value indicating whether the file or directory exists on the console or not.</returns> internal static bool ExistsImpl(string systemIpAddress, XboxPath path, Func <XboxFileSystemInfoDefinition, bool> additionalExistsPredicate, XboxConsoleAdapterBase consoleAdapter) { XboxFileSystemInfoDefinition definition; try { definition = consoleAdapter.GetFileSystemInfoDefinition(systemIpAddress, path); } catch (FileNotFoundException) { return(false); } catch (UnauthorizedAccessException) { // Following the same approach as in .NET, returning false without throwing an exception in case of insufficient permissions: // http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx return(false); } if (additionalExistsPredicate != null) { return(additionalExistsPredicate(definition)); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="XboxFileInfo"/> class. /// </summary> /// <param name="definition">The definition object describing this file.</param> /// <param name="console">The console on which the file resides.</param> internal XboxFileInfo(XboxFileSystemInfoDefinition definition, XboxConsole console) : base(definition, console) { if (definition.FileAttributes.HasFlag(FileAttributes.Directory)) { throw new ArgumentException("Cannot pass a directory to the XboxFileInfo constructor", "definition"); } }
/// <summary> /// Initializes a new instance of the <see cref="XboxFileSystemInfo"/> class. /// </summary> /// <param name="definition">The definition of this file sytsem object.</param> /// <param name="console">The console on which this file system object resides.</param> /// <exception cref="System.ArgumentNullException">Thrown if the <paramref name="definition"/> or <paramref name="console"/> parameter is null.</exception> internal XboxFileSystemInfo(XboxFileSystemInfoDefinition definition, XboxConsole console) : base(console) { if (definition == null) { throw new ArgumentNullException("definition"); } this.XboxPath = definition.Path; this.definition = definition; }
/// <summary> /// Refreshes this instance. /// </summary> public void Refresh() { lock (this.definitionLock) { try { this.definition = this.Console.Adapter.GetFileSystemInfoDefinition(this.Console.SystemIpAddressAndSessionKeyCombined, this.XboxPath); } catch (FileNotFoundException) { this.definition = null; } } }
/// <summary> /// Initializes a new instance of the <see cref="XboxDirectoryInfo"/> class. /// </summary> /// <param name="definition">The definition of the directory.</param> /// <param name="console">The console on which the directory resides.</param> internal XboxDirectoryInfo(XboxFileSystemInfoDefinition definition, XboxConsole console) : base(definition, console) { }