protected void LoadXml() { IMediaFile file = ( IMediaFile )_kernel.FindPath("ms0:/registry.xml"); Debug.Assert(file != null); if (file == null) { Log.WriteLine(Verbosity.Critical, Feature.Bios, "Registry not found - make sure you have registry.xml (and font/) on your memory stick!"); return; } using (Stream stream = file.Open(MediaFileMode.Normal, MediaFileAccess.Read)) { Debug.Assert(stream != null); XPathDocument document = new XPathDocument(stream); XPathNavigator navigator = document.CreateNavigator(); XPathNavigator node = navigator.SelectSingleNode("/registry"); this.LoadXmlDirectory(node, _system); } }
public int realIoOpen(int fileName, int flags, int mode, bool async) { string path = _kernel.ReadString(( uint )fileName); if (string.IsNullOrEmpty(path) == true) { return(-1); } IMediaItem item = _kernel.FindPath(path); if (item is IMediaFolder) { // Block access? Debug.Assert(item.Device is IUmdDevice); IUmdDevice umd = ( IUmdDevice )item.Device; Stream stream = umd.OpenImageStream(); if (stream == null) { Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoOpen: could not open image stream '{0}'", path); if (async == true) { KFile fakehandle = new KFile(_kernel, false); fakehandle.Result = 0x80010002; fakehandle.PendingClose = true; _kernel.AddHandle(fakehandle); return(( int )fakehandle.UID); } return(-1); } KDevice dev = _kernel.FindDevice(umd); Debug.Assert(dev != null); KFile handle = new KFile(_kernel, dev, item, stream); handle.IsBlockAccess = true; _kernel.AddHandle(handle); handle.Result = handle.UID; Log.WriteLine(Verbosity.Verbose, Feature.Bios, "sceIoOpen: opened block access on {0} with ID {1:X}", path, handle.UID); return(( int )handle.UID); } else { IMediaFile file = ( IMediaFile )item; if (file == null) { // Create if needed if ((flags & 0x0200) != 0) { string newName; IMediaFolder parent; if (path.IndexOf('/') >= 0) { string parentPath = path.Substring(0, path.LastIndexOf('/')); newName = path.Substring(path.LastIndexOf('/') + 1); parent = ( IMediaFolder )_kernel.FindPath(parentPath); } else { newName = path; parent = _kernel.CurrentPath; } if (parent == null) { Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoOpen: could not find parent to create file '{0}' in on open", path); if (async == true) { KFile fakehandle = new KFile(_kernel, false); fakehandle.Result = 0x80010002; fakehandle.PendingClose = true; _kernel.AddHandle(fakehandle); return(( int )fakehandle.UID); } return(-1); } file = parent.CreateFile(newName); } else { Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoOpen: could not find path '{0}'", path); if (async == true) { KFile fakehandle = new KFile(_kernel, false); fakehandle.Result = 0x80010002; fakehandle.PendingClose = true; _kernel.AddHandle(fakehandle); return(( int )fakehandle.UID); } return(unchecked (( int )0x8002012f)); } } /* * #define PSP_O_RDONLY 0x0001 #define PSP_O_WRONLY 0x0002 #define PSP_O_RDWR (PSP_O_RDONLY | PSP_O_WRONLY) #define PSP_O_NBLOCK 0x0004 #define PSP_O_DIROPEN 0x0008 // Internal use for dopen #define PSP_O_APPEND 0x0100 #define PSP_O_CREAT 0x0200 #define PSP_O_TRUNC 0x0400 #define PSP_O_EXCL 0x0800 #define PSP_O_NOWAIT 0x8000*/ MediaFileMode fileMode = MediaFileMode.Normal; if ((flags & 0x0100) == 0x0100) { fileMode = MediaFileMode.Append; } if ((flags & 0x0400) == 0x0400) { fileMode = MediaFileMode.Truncate; } MediaFileAccess fileAccess = MediaFileAccess.ReadWrite; if ((flags & 0x0001) == 0x0001) { fileAccess = MediaFileAccess.Read; } if ((flags & 0x0002) == 0x0002) { fileAccess = MediaFileAccess.Write; } if ((flags & 0x0003) == 0x0003) { fileAccess = MediaFileAccess.ReadWrite; } if ((flags & 0x0800) != 0) { // Exclusive O_EXCL //int x = 1; } if ((flags & 0x8000) != 0) { // Non-blocking O_NOWAIT //int x = 1; } if ((flags & 0x0004) != 0) { // ? O_NBLOCK //int x = 1; } Stream stream = file.Open(fileMode, fileAccess); if (stream == null) { Log.WriteLine(Verbosity.Normal, Feature.Bios, "sceIoOpen: could not open stream on file '{0}' for mode {1} access {2}", path, fileMode, fileAccess); return(-1); } IMediaDevice device = file.Device; KDevice dev = _kernel.FindDevice(file.Device); Debug.Assert(dev != null); KFile handle = new KFile(_kernel, dev, file, stream); _kernel.AddHandle(handle); handle.Result = handle.UID; Log.WriteLine(Verbosity.Verbose, Feature.Bios, "sceIoOpen: opened file {0} with ID {1:X}", path, handle.UID); return(( int )handle.UID); } }