Пример #1
0
        /// <summary>
        /// Creates a file on the xbox.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="createDisposition">Creation options.</param>
        public void CreateFile(string fileName, XboxFileMode createDisposition)
        {
            using (_xbox.CommandSession.ExtendReceiveTimeout(ReceiveTimeoutDelay))
            {
                switch (createDisposition)
                {
                case XboxFileMode.Open:
                    if (!FileExists(fileName))
                    {
                        throw new FileNotFoundException("File does not exist.");
                    }
                    break;

                case XboxFileMode.Create:
                    _xbox.CommandSession.SendCommandStrict("fileeof name=\"" + fileName + "\" size=0 cancreate");
                    break;

                case XboxFileMode.CreateNew:
                    _xbox.CommandSession.SendCommandStrict("fileeof name=\"" + fileName + "\" size=0 mustcreate");
                    break;

                default:
                    throw new NotSupportedException("Unsupported FileMode.");
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Establishes a stream to the specified file name on an Xbox using the desired <see cref="FileMode"/>.
        /// </summary>
        /// <param name="xbox"></param>
        /// <param name="fileName"></param>
        /// <param name="mode"></param>
        public XboxFileStream(Xbox xbox, string fileName, XboxFileMode mode)
        {
            if (xbox == null)
            {
                throw new ArgumentNullException(nameof(xbox));
            }

            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            if (xbox.DebugMonitor.Version.Build < 4531)
            {
                throw new NotSupportedException("Requires xbdm.dll version 4531 or higher");
            }

            _xbox = xbox;
            Name  = fileName;
            xbox.FileSystem.CreateFile(fileName, mode);

            _xbox.Logger?.Trace("Creating stream access to {0}", fileName);
        }